@@ -361,6 +361,21 @@ CachingOnDiskFileSystemImpl::makeSymlinkTo(DirectoryEntry &Parent,
361361 TargetStorage.Path );
362362}
363363
364+ static bool is_executable (StringRef TreePath, sys::fs::file_status Status,
365+ sys::path::Style PathStyle) {
366+ #ifndef _WIN32
367+ return Status.permissions () & sys::fs::perms::owner_exe;
368+ #else
369+ // This isn't the most reliable way but does better than just
370+ // checking owner_exe because most owned files have all_all
371+ // permission regardless of they are executable files.
372+ StringRef FilePath = getFilePath (TreePath, PathStyle);
373+ return (Status.permissions () & sys::fs::perms::owner_exe) &&
374+ (FilePath.ends_with_insensitive (" .exe" ) ||
375+ sys::fs::exists (FilePath + " .exe" ));
376+ #endif
377+ }
378+
364379Expected<FileSystemCache::DirectoryEntry *>
365380CachingOnDiskFileSystemImpl::makeFile (DirectoryEntry &Parent,
366381 StringRef TreePath, sys::fs::file_t F,
@@ -376,8 +391,8 @@ CachingOnDiskFileSystemImpl::makeFile(DirectoryEntry &Parent,
376391 return Handle.takeError ();
377392 // Do not trust Status.size() in case the file is volatile.
378393 return &Cache->makeFile (Parent, TreePathStorage.Path , *Node,
379- Handle->getData ().size (),
380- Status. permissions () & sys::fs::perms::owner_exe );
394+ Handle->getData ().size (),
395+ is_executable (TreePath, Status, Cache-> getPathStyle ()) );
381396}
382397
383398Expected<FileSystemCache::DirectoryEntry *>
0 commit comments