summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Path.inc
Commit message (Collapse)AuthorAgeFilesLines
* [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
* Convert a member variable to a local variable. NFC.Rafael Espindola2014-12-161-3/+3
| | | | llvm-svn: 224311
* Remove unused member and simplify. NFC.Rafael Espindola2014-12-161-22/+3
| | | | llvm-svn: 224309
* Remove silly left over from the Windows resize_file implementation.Rafael Espindola2014-12-121-1/+0
| | | | | | | I didn't notice the problem first because on a non debug build the CRT was just exiting the process without any message. llvm-svn: 224139
* Pass a FD to resise_file and add a testcase.Rafael Espindola2014-12-121-12/+4
| | | | | | I will add a real use in another commit. llvm-svn: 224136
* Remove a convoluted way of calling close by moving the call to the only caller.Rafael Espindola2014-12-111-39/+7
| | | | | | As a bonus we can actually check the return value. llvm-svn: 224046
* Remove dead code. NFC.Rafael Espindola2014-12-111-48/+0
| | | | llvm-svn: 224029
* More long path name support on Windows, this time in program execution.Paul Robinson2014-11-241-4/+8
| | | | | | | Allows long paths for the executable and redirected stdin/stdout/stderr. Addresses PR21563. llvm-svn: 222671
* silence gcc 4.9.1 warning in /llvm/lib/Support/Windows/Path.inc:564:39:Yaron Keren2014-11-171-1/+1
| | | | | | | warning: suggest parentheses around assignment used as truth value [-Wparentheses] if (ec = widenPath(path, path_utf16)) llvm-svn: 222122
* Improve long path name support on Windows.Paul Robinson2014-11-131-38/+66
| | | | | | | | | | Windows normally limits the length of an absolute path name to 260 characters; directories can have lower limits. These limits increase to about 32K if you use absolute paths with the special '\\?\' prefix. Teach Support\Windows\Path.inc to use that prefix as needed. TODO: Other parts of Support could also learn to use this prefix. llvm-svn: 221841
* Misc cleanups to the FileSytem api.Rafael Espindola2014-09-111-33/+13
| | | | | | | | | | | | | | | | The main difference is the removal of std::error_code exists(const Twine &path, bool &result); It was an horribly redundant interface since a file not existing is also a valid error_code. Now we have an access function that returns just an error_code. This is the only function that has to be implemented for Unix and Windows. The functions can_write, exists and can_execute an now just wrappers. One still has to be very careful using these function to avoid introducing race conditions (Time of check to time of use). llvm-svn: 217625
* Add writeFileWithSystemEncoding to LibLLVMSuppor.Rafael Espindola2014-09-031-4/+16
| | | | | | | | | | | | | | | | | | | | This patch adds to LLVMSupport the capability of writing files with international characters encoded in the current system encoding. This is relevant for Windows, where we can either use UTF16 or the current code page (the legacy Windows international characters). On UNIX, the file is always saved in UTF8. This will be used in a patch for clang to thoroughly support response files creation when calling other tools, addressing PR15171. On Windows, to correctly support internationalization, we need the ability to write response files both in UTF16 or the current code page, depending on the tool we will call. GCC for mingw, for instance, requires files to be encoded in the current code page. MSVC tools requires files to be encoded in UTF16. Patch by Rafael Auler! llvm-svn: 217068
* Merge TempDir and system_temp_directory.Rafael Espindola2014-08-261-17/+45
| | | | | | | | | We had two functions for finding the temp or cache directory. Each had a different set of smarts about OS specific APIs. With this patch system_temp_directory becomes the only way to do it. llvm-svn: 216460
* Remove dead code. Fixes pr20544.Rafael Espindola2014-08-081-5/+0
| | | | llvm-svn: 215243
* Finishing touch for the std::error_code transition.Rafael Espindola2014-06-131-7/+7
| | | | | | | | | | | While std::error_code itself seems to work OK in all platforms, there are few annoying differences with regards to the std::errc enumeration. This patch adds a simple llvm enumeration, which will hopefully avoid build breakages in other platforms and surprises as we get more uses of std::error_code. llvm-svn: 210920
* Fix build on windows.Rafael Espindola2014-06-131-84/+89
| | | | llvm-svn: 210873
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-4/+4
| | | | llvm-svn: 210783
* Don't import make_error_code into the llvm namespace.Rafael Espindola2014-06-121-4/+4
| | | | llvm-svn: 210772
* Don't put generic_category in the llvm namespace.Rafael Espindola2014-06-121-2/+2
| | | | llvm-svn: 210737
* Implement get_magic with generic tools and inline it.Rafael Espindola2014-06-111-42/+0
| | | | llvm-svn: 210716
* Use std::error_code instead of llvm::error_code.Rafael Espindola2014-06-111-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea of this patch is to turn llvm/Support/system_error.h into a transitional header that just brings in the erorr_code api to the llvm namespace. I will remove it shortly afterwards. The cases where the general idea needed some tweaking: * std::errc is a namespace in msvc, so we cannot use "using std::errc". I could add an #ifdef, but there were not that many uses, so I just added std:: to them in this patch. * Template specialization had to be moved to the std namespace in this patch set already. * The msvc implementation of default_error_condition doesn't seem to provide the same transformations as we need. Not too surprising since the standard doesn't actually say what "equivalent" means. I fixed the problem by keeping our old mapping and using it at error_code construction time. Despite these shortcomings I think this is still a good thing. Some reasons: * The different implementations of system_error might improve over time. * It removes 925 lines of code from llvm already. * It removes 6313 bytes from the text segment of the clang binary when it is built with gcc and 2816 bytes when building with clang and libstdc++. llvm-svn: 210687
* Remove windows_error.Rafael Espindola2014-06-111-30/+36
| | | | | | | | | | MSVC doesn't seem to provide any is_error_code_enum enumeration for the windows errors. Fortunately very few places in llvm have to handle raw windows errors, so we can just construct the corresponding error_code directly. llvm-svn: 210631
* Turn errc and windows_error into enum classes.Rafael Espindola2014-05-311-2/+2
| | | | llvm-svn: 209957
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-311-25/+25
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209952
* delete dead code.Rafael Espindola2014-05-311-11/+0
| | | | llvm-svn: 209938
* support: add a utility function to normalise path separatorsSaleem Abdulrasool2014-03-111-0/+5
| | | | | | | | Add a utility function to convert the Windows path separator to Unix style path separators. This is used by a subsequent change in clang to enable the use of Windows SDK headers on Linux. llvm-svn: 203611
* Cleanup the interface for creating soft or hard links.Rafael Espindola2014-03-111-1/+2
| | | | | | | | | | | | Before this patch the unix code for creating hardlinks was unused. The code for creating symbolic links was implemented in lib/Support/LockFileManager.cpp and the code for creating hard links in lib/Support/*/Path.inc. The only use we have for these is in LockFileManager.cpp and it can use both soft and hard links. Just have a create_link function that creates one or the other depending on the platform. llvm-svn: 203596
* Revert create_symbolic_link and both depending changesReid Kleckner2014-03-061-19/+0
| | | | | | | | | | This reverts commits r203136, r203137, and r203138. This code doesn't build on Windows. Even on Vista+, Windows requires elevated privileges to create a symlink. Therefore we can't use symlinks in the compiler. We'll have to find another approach. llvm-svn: 203143
* [Support/FileSystem] Introduce llvm::sys::fs::create_symbolic_link().Argyrios Kyrtzidis2014-03-061-0/+19
| | | | llvm-svn: 203136
* [C++11] Remove the R-value reference #if usage from the ADT and SupportChandler Carruth2014-03-011-2/+0
| | | | | | libraries. It is now always 1 in LLVM builds. llvm-svn: 202580
* Replace the F_Binary flag with a F_Text one.Rafael Espindola2014-02-241-1/+1
| | | | | | | | | After this I will set the default back to F_None. The advantage is that before this patch forgetting to set F_Binary would corrupt a file on windows. Forgetting to set F_Text produces one that cannot be read in notepad, which is a better failure mode :-) llvm-svn: 202052
* Share a createUniqueEntity implementation between unix and windows.Rafael Espindola2014-02-241-130/+13
| | | | | | | The only extra bit of functionality that had to be exposed for this be be implemented in Path.cpp is opening a file in rw mode. llvm-svn: 202005
* Use static instead of an anonymous namespace.Rafael Espindola2014-02-231-21/+19
| | | | llvm-svn: 201983
* Simplify remove, create_directory and create_directories.Rafael Espindola2014-02-231-32/+20
| | | | | | | | | | | | | | | Before this patch they would take an boolean argument to say if the path already existed. This was redundant with the returned error_code which is able to represent that. This allowed for callers to incorrectly check only the existed flag instead of first checking the error code. Instead, pass in a boolean flag to say if the previous (non-)existence should be an error or not. Callers of the of the old simple versions are not affected. They still ignore the previous (non-)existence as they did before. llvm-svn: 201979
* [Support] Correctly handle zero length inputs to UTF conversion functions on ↵Michael J. Spencer2014-02-201-32/+30
| | | | | | Windows. llvm-svn: 201811
* Remove dead code.Rafael Espindola2014-02-131-32/+0
| | | | llvm-svn: 201327
* Rename Windows.h to WindowsSupport.h to avoid ambiguityReid Kleckner2014-02-121-1/+1
| | | | llvm-svn: 201258
OpenPOWER on IntegriCloud