mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
Make vim startup faster
It appears that GetFileAttributes(u"\\etc\\passwd") can take two seconds on Windows 10 at unpredictable times for reasons which are mysterious to me. Let's try avoiding that path entirely and pray to Microsoft it works
This commit is contained in:
parent
deb5e07b5a
commit
a5c0189bf6
5 changed files with 25 additions and 15 deletions
|
@ -75,6 +75,7 @@ static textwindows int __mkntpathath_impl(int64_t dirhand, const char *path,
|
|||
|
||||
return n;
|
||||
} else {
|
||||
filelen = __normntpath(file, filelen);
|
||||
return filelen;
|
||||
}
|
||||
}
|
||||
|
@ -84,23 +85,20 @@ textwindows int __mkntpathath(int64_t dirhand, const char *path, int flags,
|
|||
|
||||
// convert the path.
|
||||
int len;
|
||||
if ((len = __mkntpathath_impl(dirhand, path, flags, file)) == -1) {
|
||||
if ((len = __mkntpathath_impl(dirhand, path, flags, file)) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// if path ends with a slash, then we need to manually do what linux
|
||||
// does and check to make sure it's a directory, and return ENOTDIR,
|
||||
// since WIN32 will reject the path with EINVAL if we don't do this.
|
||||
if (len && file[len - 1] == '\\') {
|
||||
uint32_t fattr;
|
||||
if (len > 1 && !(len == 3 && file[1] == ':')) {
|
||||
if (len > 1 && !(len == 3 && file[1] == ':'))
|
||||
file[--len] = 0;
|
||||
}
|
||||
if ((fattr = GetFileAttributes(file)) != -1u &&
|
||||
!(fattr & kNtFileAttributeReparsePoint) &&
|
||||
!(fattr & kNtFileAttributeDirectory)) {
|
||||
!(fattr & kNtFileAttributeDirectory))
|
||||
return enotdir();
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue