summaryrefslogtreecommitdiff
path: root/lib/Support/Path.cpp
Commit message (Collapse)AuthorAge
* Path: Recognize COFF import library file magic.Rui Ueyama2013-11-15
| | | | | | | | | | | | Summary: Make identify_magic to recognize COFF import file. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2165 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194852 91177308-0d34-0410-b5e6-96231b3b80d8
* Recognize 0x0000 as a COFF file magic.Rui Ueyama2013-11-14
| | | | | | | | | | | | | | | Summary: Some machine-type-neutral object files containing only undefined symbols actually do exist in the Windows standard library. Need to recognize them as COFF files. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2164 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194734 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in Windows resource file detection.Rui Ueyama2013-10-16
| | | | | | The magic bytes should not include the trailing NUL byte. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192769 91177308-0d34-0410-b5e6-96231b3b80d8
* Path: Recognize Windows compiled resource file.Rui Ueyama2013-10-15
| | | | | | | | | | | | | | Some background: One can pass compiled resource files (.res files) directly to the linker on Windows. If a resource file is given, the linker will run "cvtres" command in background to convert the resource file to a COFF file to link it. What I'm trying to do with this patch is to make the linker to recognize the resource file by file magic, so that it can run cvtres command. Differential Revision: http://llvm-reviews.chandlerc.com/D1943 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192742 91177308-0d34-0410-b5e6-96231b3b80d8
* Path: Add an in-place version of path::native.Benjamin Kramer2013-09-11
| | | | | | | | This reflects the common use case of nativizing a prepared path. The existing version invokes undefined behavior if input = output, add an assert to catch that case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190510 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixes a bug when iterating on pathsTareq A. Siraj2013-08-12
| | | | | | | | | | This fixes the incorrect implementation of iterating on file/directory paths. Differential Review: http://llvm-reviews.chandlerc.com/D1277 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188183 91177308-0d34-0410-b5e6-96231b3b80d8
* Include st_dev to make the result of getUniqueID actually unique.Rafael Espindola2013-07-29
| | | | | | This will let us use getUniqueID instead of st_dev directly on clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187378 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't end a file name with a dot. It looks odd.Rafael Espindola2013-07-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187124 91177308-0d34-0410-b5e6-96231b3b80d8
* Split openFileForWrite into windows and unix versions.Rafael Espindola2013-07-19
| | | | | | It is similar to 186511, but for creating files for writing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186679 91177308-0d34-0410-b5e6-96231b3b80d8
* Split openFileForRead into Windows and Unix versions.Rafael Espindola2013-07-17
| | | | | | | | | | | This has some advantages: * Lets us use native, utf16 windows functions. * Easy to produce good errors on windows about trying to use a directory when we want a file. * Simplifies the unix version a bit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186511 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a wrapper for open.Rafael Espindola2013-07-16
| | | | | | | This centralizes the handling of O_BINARY and opens the way for hiding more differences (like how open behaves with directories). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186447 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unique_file now that it is unused.Rafael Espindola2013-07-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185728 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a createUniqueFile function and switch llvm's users of unique_file.Rafael Espindola2013-07-05
| | | | | | | | | | | | | | This function is complementary to createTemporaryFile. It handles the case were the unique file is *not* temporary: we will rename it in the end. Since we will rename it, the file has to be in the same filesystem as the final destination and we don't prepend the system temporary directory. This has a small semantic difference from unique_file: the default mode is 0666. This matches the behavior of most unix tools. For example, with this change lld now produces files with the same permissions as ld. I will add a test of this change when I port clang over to createUniqueFile (next commit). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185726 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a higher level createTemporaryFile function.Rafael Espindola2013-07-05
| | | | | | | | This function is inspired by clang's Driver::GetTemporaryPath. It hides the pattern used for uniquing and requires simple file names that are always placed in the system temporary directory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185716 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve comment.Rafael Espindola2013-06-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185141 91177308-0d34-0410-b5e6-96231b3b80d8
* Improvements to unique_file and createUniqueDirectory.Rafael Espindola2013-06-28
| | | | | | | | | | | | | | | | | | | * Don't try to create parent directories in unique_file. It had two problem: * It violates the contract that it is atomic. If the directory creation success and the file creation fails, we would return an error but the file system was modified. * When creating a temporary file clang would have to first check if the parent directory existed or not to avoid creating one when it was not supposed to. * More efficient implementations of createUniqueDirectory and the unique_file that produces only the file name. Now all 3 just call into a static function passing what they want (name, file or directory). Clang also has to be updated, so tests might fail if a bot picks up this commit and not the corresponding clang one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185126 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't ask for a mode when we are not keeping the file.Rafael Espindola2013-06-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185123 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a convenience createUniqueDirectory function.Rafael Espindola2013-06-27
| | | | | | | | | | | There are a few valid situation where we care about the structure inside a directory, but not about the directory itself. A simple example is for unit testing directory traversal. PathV1 had a function like this, add one to V2 and port existing users of the created temp file and delete it hack to using it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185059 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename PathV2 to just Path now that it is the only one.Rafael Espindola2013-06-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185015 91177308-0d34-0410-b5e6-96231b3b80d8
* PathV1 is deprecated since the 18th of Dec 2010. Remove it.Rafael Espindola2013-06-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184960 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove Path::isObjectFile.Rafael Espindola2013-06-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184305 91177308-0d34-0410-b5e6-96231b3b80d8
* Inline Path::isBitcodeFile into only use and remove it.Rafael Espindola2013-06-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183840 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove Path::hasMagicNumber.Rafael Espindola2013-06-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183838 91177308-0d34-0410-b5e6-96231b3b80d8
* Include PathV1.h in files that use it.Rafael Espindola2013-06-11
| | | | | | This is preparation for replacing Path.h with PathV2.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183782 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove Path::getDirname.Rafael Espindola2013-06-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183780 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove GetDLLSuffix.Rafael Espindola2013-06-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183777 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove GetSystemLibraryPaths.Rafael Espindola2013-06-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183770 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused FindLibrary function.Rafael Espindola2013-06-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183764 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove sys::identifyFileType.Rafael Espindola2013-06-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183763 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass a StringRef to sys::identifyFileType.Rafael Espindola2013-06-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183669 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix an out of bounds array access.Rafael Espindola2013-06-10
| | | | | | | We were looking at Magic[5] without checking Length. Since this path would not return unless Length >= 18 anyway, just move the >= 18 check up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183666 91177308-0d34-0410-b5e6-96231b3b80d8
* Update for current naming conventions.Rafael Espindola2013-06-10
| | | | | | I will change identifyFileType to use a StringRef in the next patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183664 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove duplicate includes.Roman Divacky2012-12-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170902 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-03
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* PR13013: ELF Type identification fails for MSB type ELF files.Meador Inge2012-06-25
| | | | | | | | | | Fix 'sys::IdentifyFileType' to work with big and little endian byte orderings when reading the ELF object file type. Initial patch by Stefan Hepp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159138 91177308-0d34-0410-b5e6-96231b3b80d8
* Support/FileSystem: Add file_magic and move a vew clients over to it.Michael J. Spencer2011-12-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146523 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup whitespace.Michael J. Spencer2011-12-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146521 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a couple unused methods. PR11201.Eli Friedman2011-11-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143452 91177308-0d34-0410-b5e6-96231b3b80d8
* ObjectFile: Add support for mach-o-style dSYM companion files.Benjamin Kramer2011-09-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139676 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for 64-bit object files to Path.Eric Christopher2011-04-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129975 91177308-0d34-0410-b5e6-96231b3b80d8
* Assorted bugfixes in object file handling:Eric Christopher2011-04-03
| | | | | | | | | | | | | | | | | | | | | | | | | - Adds support for sniffing PE/COFF files on win32 (.exe and .dll) which are COFF files that have an MS-DOS compatibility stub on the front of them. - Fixes a bug in the COFFObjectFile's support for the Microsoft COFF extension for long symbol names, wherein it was attempting to parse the leading '/' in an extended symbol name reference as part of the integer offset. - Fixes bugs in COFFObjectFile and ELFObjectFile wherein section and symbol iterators were being returned with uninitialized bytes; the type DataRefImpl is a union between 2 32-bit words (d.a and d.b) and a single intptr_t word (p). Only p was being initialized, so in 32-bit builds the result would be iterators with random upper 32-bit words in their DataRefImpls. This caused random failures when seeking around in object files. Patch by Graydon Hoare! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128799 91177308-0d34-0410-b5e6-96231b3b80d8
* Support/PathV2: Add identify_magic.Michael J. Spencer2011-01-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123548 91177308-0d34-0410-b5e6-96231b3b80d8
* Support/Path: Deprecate PathV1::exists and replace all uses with ↵Michael J. Spencer2011-01-10
| | | | | | PathV2::fs::exists. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123151 91177308-0d34-0410-b5e6-96231b3b80d8
* Support/Path: Deprecate Path::hasMagicNumber and replace all uses with ↵Michael J. Spencer2010-12-28
| | | | | | fs::has_magic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122589 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete Path::appendSuffix's return value; it wasn't used anywhere, whichDan Gohman2010-12-01
| | | | | | | is fine since isn't really necessary to check isValid there anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120538 91177308-0d34-0410-b5e6-96231b3b80d8
* Merge System into Support.Michael J. Spencer2010-11-29
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120298 91177308-0d34-0410-b5e6-96231b3b80d8