summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Path.inc
Commit message (Collapse)AuthorAgeFilesLines
...
* [Support, Windows] Handle long paths with unix separatorsPirama Arumuga Nainar2017-08-211-4/+7
| | | | | | | | | | | | | | | | | | Summary: The function widenPath() for Windows also normalizes long path names by iterating over the path's components and calling append(). The assumption during the iteration that separators are not returned by the iterator doesn't hold because the iterators do return a separator when the path has a drive name. Handle this case by ignoring separators during iteration. Reviewers: rnk Subscribers: danalbert, srhines Differential Revision: https://reviews.llvm.org/D36752 llvm-svn: 311382
* [Support] Use FILE_SHARE_DELETE to fix RemoveFileOnSignal on WindowsReid Kleckner2017-08-041-3/+4
| | | | | | | | | | | | | | | | | Summary: Tools like clang that use RemoveFileOnSignal on their output files weren't actually able to clean up their outputs before this change. Now the call to llvm::sys::fs::remove succeeds and the temporary file is deleted. This is a stop-gap to fix clang before implementing the solution outlined in PR34070. Reviewers: davide Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D36337 llvm-svn: 310137
* [Support] Remove getPathFromOpenFD, it was unusedReid Kleckner2017-08-041-36/+0
| | | | | | | | | | | | | | Summary: It was added to support clang warnings about includes with case mismatches, but it ended up not being necessary. Reviewers: twoh, rafael Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D36328 llvm-svn: 310078
* [Support] Fill the file_status struct with link count.Zachary Turner2017-03-201-1/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D31110 llvm-svn: 298326
* [Support] Support both Windows and Posix paths on both platforms.Zachary Turner2017-03-161-1/+1
| | | | | | | | | | | | | | | | | | Previously which path syntax we supported dependend on what platform we were compiling LLVM on. While this is normally desirable, there are situations where we need to be able to handle a path that we know was generated on a remote host. Remote debugging, for example, or parsing debug info. 99% of the code in LLVM for handling paths was platform agnostic and literally just a few branches were gated behind pre-processor checks, so this changes those sites to use runtime checks instead, and adds a flag to every path API that allows one to override the host native syntax. Differential Revision: https://reviews.llvm.org/D30858 llvm-svn: 298004
* [Support] Add support for getting file system permissions on Windows and ↵James Henderson2017-03-161-7/+40
| | | | | | | | | | | | | | | | | | implement sys::fs::set/getPermissions to work with them This change adds support for functions to set and get file permissions, in a similar manner to the C++17 permissions() function in <filesystem>. The setter uses chmod on Unix systems and SetFileAttributes on Windows, setting the permissions as passed in. The getter simply uses the existing status() function. Prior to this change, status() would always return an unknown value for the permissions on a Windows file, making it impossible to test the new function on Windows. I have therefore added support for this as well. On Linux, prior to this change, the permissions included the file type, which should actually be accessed via a different member of the file_status class. Note that on Windows, only the *_write permission bits have any affect - if any are set, the file is writable, and if not, the file is read-only. This is in common with what MSDN describes for their behaviour of std::filesystem::permissions(), and also what boost::filesystem does. The motivation behind this change is so that we can easily test behaviour on read-only files in LLVM unit tests, but I am sure that others may find it useful in some situations. Reviewers: zturner, amccarth, aaron.ballman Differential Revision: https://reviews.llvm.org/D30736 llvm-svn: 297945
* Reverting r297617 because it broke some bots:Aaron Ballman2017-03-131-52/+19
| | | | | | http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/49970 llvm-svn: 297618
* Add support for getting file system permissions and implement ↵Aaron Ballman2017-03-131-19/+52
| | | | | | | | sys::fs::permissions to set them. Patch by James Henderson. llvm-svn: 297617
* [Support] Don't return an error if realPath fails.Zachary Turner2017-03-101-3/+2
| | | | | | | | | | | In openFileForRead, we would not previously return an error if real_path resolution failed. After a recent patch, we started propagating this error up. This caused a failure in clang when trying to call openFileForRead("nul"). This patch restores the previous behavior of not propagating this error up. llvm-svn: 297488
* Add llvm::sys::fs::real_path.Zachary Turner2017-03-101-15/+98
| | | | | | | | | | | | | | | | | | | | | LLVM already has real_path like functionality, but it is cumbersome to use and involves clean up after (e.g. you have to call openFileForRead, then close the resulting FD). Furthermore, on Windows it doesn't work for directories since opening a directory and opening a file require slightly different flags. So I add a simple function `real_path` which works for all paths on all platforms and has a simple to use interface. In doing so, I add the ability to opt in to resolving tilde expressions (e.g. ~/foo), which are normally handled by the shell. Differential Revision: https://reviews.llvm.org/D30668 llvm-svn: 297483
* [Support] Add llvm::sys::fs::remove_directories.Zachary Turner2017-03-081-2/+31
| | | | | | | | | | | | | | | | | | | | | We already have a function create_directories() which can create an entire tree, and remove() which can remove an empty directory, but we do not have remove_directories() which can remove an entire tree. This patch adds such a function. Because removing a directory tree can have dangerous consequences when the tree contains a directory symlink, the patch here updates the existing directory_iterator construct to optionally not follow symlinks (previously it would always follow symlinks). The delete algorithm uses this flag so that for symlinks, only the links are removed, and not the targets. On Windows this is implemented with SHFileOperation, which also does not recurse into symbolic links or junctions. Differential Revision: https://reviews.llvm.org/D30676 llvm-svn: 297314
* [Support] Add the option to not follow symlinks on stat.Zachary Turner2017-03-071-17/+8
| | | | llvm-svn: 297154
* [Support] Add a function to check if a file resides locally.Zachary Turner2017-02-211-0/+74
| | | | | | Differential Revision: https://reviews.llvm.org/D30010 llvm-svn: 295768
* [Support] Add sys::fs::set_current_path() (aka chdir)Pavel Labath2017-01-241-0/+12
| | | | | | | | | | | | | | | Summary: This adds a cross-platform way of setting the current working directory analogous to the existing current_path() function used for retrieving it. The function will be used in lldb. Reviewers: rafael, silvas, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29035 llvm-svn: 292907
* [ThinLTO] Add an API to trigger file-based API for returning objects to the ↵Mehdi Amini2016-12-141-0/+4
| | | | | | | | | | | | | | | | | | | | linker Summary: The motivation is to support better the -object_path_lto option on Darwin. The linker needs to write down the generate object files on disk for later use by lldb or dsymutil (debug info are not present in the final binary). We're moving this into libLTO so that we can be smarter when a cache is enabled and hard-link when possible instead of duplicating the files. Reviewers: tejohnson, deadalnix, pcc Subscribers: dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D27507 llvm-svn: 289631
* Remove TimeValue usage from llvm/SupportPavel Labath2016-10-241-22/+12
| | | | | | | | | | | | | | | | | Summary: This is a follow-up to D25416. It removes all usages of TimeValue from llvm/Support library (except for the actual TimeValue declaration), and replaces them with appropriate usages of std::chrono. To facilitate this, I have added small utility functions for converting time points and durations into appropriate OS-specific types (FILETIME, struct timespec, ...). Reviewers: zturner, mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25730 llvm-svn: 284966
* Switch to using an API that handles non-ASCII paths appropriately on Windows.Aaron Ballman2016-06-211-10/+11
| | | | llvm-svn: 273262
* Fix a relatively nasty bug with fs::getPathFromOpenFD() on Windows. The ↵Aaron Ballman2016-06-201-4/+13
| | | | | | GetFinalPathNameByHandle API does not behave as documented; if given a buffer that has enough space for the path but not the null terminator, the call will return the number of characters required *without* the null terminator (despite being documented otherwise) and it will not set GetLastError(). The result was that this function would return a bogus path and no error. Instead, ensure there is sufficient space for a null terminator (we already strip it off manually for compatibility with older versions of Windows). llvm-svn: 273195
* In openFileForRead, attempt to fetch the actual name of the file on disk -- ↵Taewook Oh2016-06-131-1/+45
| | | | | | | | | | | | | including case -- so that clang can later warn about non-portable #include and #import directives. Differential Revision: http://reviews.llvm.org/D19842 Corresponding clang patch: http://reviews.llvm.org/D19843 Re-commit after addressing issues with of generating too many warnings for Windows and asan test failures Patch by Eric Niebler llvm-svn: 272555
* Revert commit r271704, a patch that enables warnings for non-portable ↵Taewook Oh2016-06-041-45/+1
| | | | | | #include and #import paths (Corresponding clang patch has been reverted by r271761). Patches are reverted because they generate lots of unadressable warnings for windows and fail tests under ASAN. llvm-svn: 271764
* In openFileForRead, attempt to fetch the actual name of the file on disk -- ↵Taewook Oh2016-06-031-1/+45
| | | | | | | | | | including case -- so that clang can later warn about non-portable #include and #import directives. Differential Revision: http://reviews.llvm.org/D19842 Patch by Eric Niebler llvm-svn: 271704
* Adding period to the end of a comment to test out commit access.Douglas Yung2016-05-031-1/+1
| | | | llvm-svn: 268337
* Fix Windows build (typo in disk_space() implementation)Mehdi Amini2016-04-011-1/+1
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265087
* Add disk_space() to llvm::fsMehdi Amini2016-04-011-0/+13
| | | | | | | | | | Summary: Adapted from Boost::filesystem. (This is a reapply by reverting commit r265080 and fixing the WinAPI part) Differential Revision: http://reviews.llvm.org/D18467 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265082
* Revert "Add disk_space() to llvm::fs"Mehdi Amini2016-04-011-13/+0
| | | | | | | | This reverts commit r265074 and r265068. Breaks windows build From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265080
* Use const ref instead of value for Twine in the disk_space() APIMehdi Amini2016-03-311-1/+1
| | | | | | | Thanks Rui for noticing! From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265074
* Add disk_space() to llvm::fsMehdi Amini2016-03-311-0/+13
| | | | | | | | | | Summary: Adapted from Boost::filesystem. (This is a reapply by reverting commit r265062 and fixing the WinAPI part) Differential Revision: http://reviews.llvm.org/D18467 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265068
* Revert "Add disk_space() to llvm::fs"Mehdi Amini2016-03-311-13/+0
| | | | | | | | | Breaks windows bot. This reverts commit r265050. This reverts commit r265055. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265062
* Add disk_space() to llvm::fsMehdi Amini2016-03-311-0/+13
| | | | | | | | | | | | | Summary: Adapted from Boost::filesystem. Reviewers: bruno, silvas Subscribers: tberghammer, danalbert, llvm-commits, srhines Differential Revision: http://reviews.llvm.org/D18467 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265050
* Improve the reliability of file renaming in Windows by having the compiler retrySunil Srivastava2016-03-251-16/+33
| | | | | | | | | | | the rename operation on 3 error conditions of ReplaceFileW() that it was previously bailing out on. Patch by Douglas Yung! Differential Revision: http://reviews.llvm.org/D17903 llvm-svn: 264477
* Add lastAccessedTime to file_statusMehdi Amini2016-03-251-8/+22
| | | | | | | | | Differential Revision: http://reviews.llvm.org/D18456 This is a re-commit of r264387 and r264388 after fixing a typo. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264392
* Revert "Add lastAccessedTime to file_status"Mehdi Amini2016-03-251-22/+8
| | | | | | | | This reverts commit r264387. Bots are broken in various ways, I need to take one commit at a time... From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264390
* Revert "Fix windows build for sys::fs:file_status Access Time added in r264387"Mehdi Amini2016-03-251-2/+2
| | | | | | | | This reverts commit r264388. Bots are broken in various ways, I need to take one commit at a time... From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264389
* Fix windows build for sys::fs:file_status Access Time added in r264387Mehdi Amini2016-03-251-2/+2
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264388
* Add lastAccessedTime to file_statusMehdi Amini2016-03-251-8/+22
| | | | | | | | | | | Reviewers: silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18456 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264387
* Auto-link with ole32.dll to simplify building LLVM.dllReid Kleckner2016-01-121-0/+1
| | | | | | Patch by Jakob Bornecrantz llvm-svn: 257499
* [Support] Tweak path::system_temp_directory() on Windows.Pawel Bylica2015-11-171-16/+15
| | | | | | | | | | | | | | | | | Summary: This patch changes the behavior of path::system_temp_directory() on Windows to be closer to GetTempPath Windows API call. Enforces path separator to be the native one, makes path absolute, etc. GetTempPath is not used directly because of limitations/implementation bugs on Windows 7. Windows specific unit tests are added. Most of them runs in separated process with modified environment variables. This change fixes FileSystemTest.CreateDir unittest that had been failing when run from Unix-like shell on Windows (Unix-like path separator (/) used in env variables). Reviewers: chapuni, rafael, aaron.ballman Subscribers: rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D14231 llvm-svn: 253345
* Revert r252366: [Support] Use GetTempDir to get the temporary dir path on ↵Pawel Bylica2015-11-061-10/+37
| | | | | | Windows. llvm-svn: 252367
* [Support] Use GetTempDir to get the temporary dir path on Windows.Pawel Bylica2015-11-061-37/+10
| | | | | | | | | | | | | | | Summary: In general GetTempDir follows the same logic as the replaced code: checks env variables TMP, TEMP, USERPROFILE in order. However, it also perform other checks like making separators native (\), making the path absolute, etc. This change fixes FileSystemTest.CreateDir unittest that had been failing when run from Unix-like shell on Windows (Unix-like path separator (/) used in env variables). Reviewers: chapuni, rafael, aaron.ballman Subscribers: rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D14231 llvm-svn: 252366
* Use static instead of anonymous namespace for helper functions. NFC.Pawel Bylica2015-11-021-4/+2
| | | | llvm-svn: 251801
* [Support] Extend sys::path with user_cache_directory function.Pawel Bylica2015-11-021-0/+4
| | | | | | | | | | | | | | | | | | | | Summary: The new function sys::path::user_cache_directory tries to discover a directory suitable for cache storage for current system user. On Windows and Darwin it returns a path to system-specific user cache directory. On Linux it follows XDG Base Directory Specification, what is: - use non-empty $XDG_CACHE_HOME env var, - use $HOME/.cache. Reviewers: chapuni, aaron.ballman, rafael Subscribers: rafael, aaron.ballman, llvm-commits Differential Revision: http://reviews.llvm.org/D13801 llvm-svn: 251784
* Make a bunch of static arrays const.Craig Topper2015-10-181-4/+6
| | | | llvm-svn: 250642
* Use Windows Vista API to get the user's home directoryPawel Bylica2015-10-161-7/+11
| | | | | | | | | | | | Summary: This patch replaces usage of deprecated SHGetFolderPathW with SHGetKnownFolderPath. The usage of SHGetKnownFolderPath is wrapped to allow queries for other "known" folders in the near future. Reviewers: aaron.ballman, gbedwell Subscribers: chapuni, llvm-commits Differential Revision: http://reviews.llvm.org/D13753 llvm-svn: 250501
* Fix rename() sometimes failing if another process uses openFileForRead()Greg Bedwell2015-10-121-10/+28
| | | | | | | | | | | | | | | | | | | On Windows, fs::rename() could fail is another process was reading the file at the same time using fs::openFileForRead(). In most cases the user wouldn't notice as fs::rename() will continue to retry for 2000ms. Typically this is enough for the read to complete and a retry to succeed, but if the disk is being it too hard then the response time might be longer than the retry time and the rename would fail with a permission error. Add FILE_SHARE_DELETE to the sharing flags for CreateFileW() in fs::openFileForRead() and try ReplaceFileW() prior to MoveFileExW() in fs::rename(). Based on an initial patch by Edd Dawson! Differential Revision: http://reviews.llvm.org/D13647 llvm-svn: 250046
* ScanDirForExecutable on Windows fails to find executables with the "exe" ↵Reid Kleckner2015-09-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | extension in name When the driver tries to locate a program by its name, e.g. a linker, it scans the paths provided by the toolchain using the ScanDirForExecutable function. If the lookup fails, the driver uses llvm::sys::findProgramByName. Unlike llvm::sys::findProgramByName, ScanDirForExecutable is not aware of file extensions. If the program has the "exe" extension in its name, which is very common on Windows, ScanDirForExecutable won't find it under the toolchain-provided paths. This patch changes the Windows version of the "`can_execute`" function called by ScanDirForExecutable to respect file extensions, similarly to llvm::sys::findProgramByName. Patch by Oleg Ranevskyy Reviewers: rnk Differential Revision: http://reviews.llvm.org/D12711 llvm-svn: 247358
* Thread premissions through sys::fs::create_director{y|ies}Frederic Riss2015-08-061-1/+2
| | | | llvm-svn: 244268
* Replace windows_error calls with mapWindowsError.Yaron Keren2015-05-041-29/+25
| | | | | | | | After r210687, windows_error does nothing but call mapWindowsError. Other Windows/*.inc files directly call mapWindowsError. This patch updates Path.inc and Process.inc to do the same. llvm-svn: 236409
* [FS] Report errors from llvm::sys::fs::rename on WindowsReid Kleckner2015-04-101-0/+1
| | | | | | | | | | Previously we would always report success, which is pretty bogus. I'm too lazy to write a test where rename will portably fail on all platforms. I'm just trying to fix breakage introduced by r234597, which happened to tickle this. llvm-svn: 234611
* Remove many superfluous SmallString::str() calls.Yaron Keren2015-03-181-2/+2
| | | | | | | | | | | | | | | Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
* Remove the last unnecessary member variable of mapped_file_region. NFC.Rafael Espindola2014-12-161-11/+6
| | | | llvm-svn: 224312
OpenPOWER on IntegriCloud