Commit Graph

41 Commits

Author SHA1 Message Date
Reid Spencer
6371ccbd8d Two changes:
1. Use isValid() to check validity of the resulting path name in the
   eraseSuffix even though we can't think of a case where eraseSuffix could
   possibly cause an invalid path name.
2. Rewrite isValid() to not use the deprecated realpath function any more.
   It now just uses isascii to make sure all the characters are legit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22359 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-08 06:53:26 +00:00
Jeff Cohen
85c716f83d Stamp out tabs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22357 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-08 05:02:13 +00:00
Jeff Cohen
563a17fb35 Fix eraseSuffix()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22355 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-08 04:49:16 +00:00
Reid Spencer
a229c5cce7 Final Changes For PR495:
This chagne just renames some sys::Path methods to ensure they are not
misused. The Path documentation now divides methods into two dimensions:
Path/Disk and accessor/mutator. Path accessors and mutators only operate
on the Path object itself without making any disk accesses. Disk accessors
and mutators will also access or modify the file system. Because of the
potentially destructive nature of disk mutators, it was decided that all
such methods should end in the work "Disk" to ensure the user recognizes
that the change will occur on the file system. This patch makes that
change. The method name changes are:

makeReadable        -> makeReadableOnDisk
makeWriteable       -> makeWriteableOnDisk
makeExecutable      -> makeExecutableOnDisk
setStatusInfo       -> setStatusInfoOnDisk
createDirectory     -> createDirectoryOnDisk
createFile          -> createFileOnDisk
createTemporaryFile -> createTemporaryFileOnDisk
destroy             -> eraseFromDisk
rename              -> renamePathOnDisk

These changes pass the Linux Deja Gnu tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22354 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-08 03:08:58 +00:00
Reid Spencer
dd04df0ec3 For PR495:
Get rid of the difference between file paths and directory paths. The Path
class now simply stores a path that can refer to either a file or a
directory. This required various changes in the implementation and interface
of the class with the corresponding impact to its users. Doxygen comments were
also updated to reflect these changes. Interface changes are:

appendDirectory -> appendComponent
appendFile -> appendComponent
elideDirectory -> eraseComponent
elideFile -> eraseComponent
elideSuffix -> eraseSuffix
renameFile -> rename
setDirectory -> set
setFile -> set

Changes pass Dejagnu and llvm-test/SingleSource tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22349 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-07 23:21:43 +00:00
Reid Spencer
c7f083297c For PR495:
Change interface to Path class:
readable -> canRead
writable -> canWrite
executable -> canExecute

More (incremental) changes coming to close 495.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22345 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-07 18:21:42 +00:00
Reid Spencer
932e2e33eb Put in a hack for Cygwin that prevents mkdtemp from being used since
configure seems to find it on Cygwin but linking against it fails.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22189 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-02 05:38:20 +00:00
Misha Brukman
6b8a63ae58 Remove vim settings from source code; people should use llvm/utils/vim/vimrc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21704 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-05 22:33:09 +00:00
Reid Spencer
2aafadcc76 For Bug 543:
Standardize the error messages to be in "path: what failed: why" format.
Also attempt to use the correct errno to ThrowErrno in situations where
the errno value is erased by subsequent system calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21385 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 02:50:10 +00:00
Misha Brukman
8177bf8904 Do not mark directories as `executable', we only want program files
Patch by Markus Oberhumer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21377 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-20 15:33:22 +00:00
Misha Brukman
4619c75f64 Ignore dangling symlinks in getDirectoryContents()
Thanks to Markus Oberhumer for the patch!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21370 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-20 04:04:07 +00:00
Reid Spencer
1af69a8131 Be slightly more accurate in an error message.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20397 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-02 05:45:56 +00:00
Reid Spencer
af2f208e7c For PR351:
* Ensure #includes are wrapped with appropriate HAVE_ guards
* Ensure variations in "dirent" structure are accounted for.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19158 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-27 06:17:15 +00:00
Reid Spencer
69a1616106 For PR351:
Merge implementations of isValid and GetTemporaryDirectory into this file. There
is not any point having the operating system specific files for such little
variation between the Unix family of systems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19134 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-24 06:29:42 +00:00
Reid Spencer
78076f6140 Put the CopyFile function explicitly in the sys namespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19079 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-21 03:27:08 +00:00
Misha Brukman
210b32b16f * Use "" for LLVM include files, not <>
* llvm/Config/alloca.h already #includes config.h
* Minor readability/stylistic changes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19048 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-20 00:16:38 +00:00
Reid Spencer
00e8930206 Change the signatures of the destroyFile and destroyDirectory methods to
const because they affect the file system, not the Path object.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18973 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-15 23:02:10 +00:00
Reid Spencer
835b6941fd Remove automatic insertion of CFE's lib directory into the bytecode path
because LLVM should be agnostic to the needs of specific front ends.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18968 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-15 22:21:42 +00:00
Reid Spencer
07f9f4e2a4 Fix a file overwrite bug in llvm-ar introduced by changes to
createTemporaryFile semantics where it doesn't create a fully unique name
if the basename doesn't exist. This functionality is now optionally
provided by the boolean reuse_current parameter to createTemporaryFile and
makeUnique. The default values differ because of the way these functions
are used in LLVM.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18961 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-15 08:32:45 +00:00
Reid Spencer
c29befb554 For PR351:
* Fix implementation and documentation about LLVMGCCDIR/bytecode-libs
* Add the makeUnique method, replacement for getUniqueFilename in Support.
* Add the sys::CopyFile function, replacement for CopyFile in Support.
* Move GetLLVMConfigDir() into generic code area since its generic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18947 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-15 01:50:13 +00:00
Reid Spencer
77cc91deaa For PR351:
Implement three new functions to allow setting access/permission bits on
the file referenced by a path. The makeReadable and makeExecutable methods
replace the FileUtilities MakeFileReadable and MakeFileExecutable
functions. The makeWritable function is new and provided for consistency
since Path has a writable() method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18907 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-13 19:59:50 +00:00
Reid Spencer
3d595cba33 Remove an always false clause from an if statement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18885 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-13 07:51:07 +00:00
Alkis Evlogimenos
07941b493d Fix a bug where directory names of length one or less where not set
properly (examples: "", ".", "a").


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18883 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-13 07:41:35 +00:00
Reid Spencer
732f92d56e * Add a std::ostream inserter for sys::Path
* Correct the std::string constructor to take a const reference.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18877 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-13 06:57:15 +00:00
Reid Spencer
1b6b99bffc For PR351: \
* Remove IsLibrary and GetLibraryPath, replaced by FindLibrary in ../Path.cpp \
* Implement GetSystemLibraryPaths and GetBytecodeLibraryPaths, instead of the \
  GetSystemLibraryPath1 and GetSystemLibraryPath2 methods


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18862 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-13 03:00:51 +00:00
Reid Spencer
1fce09125c Path::get -> Path::toString
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18785 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-11 00:14:15 +00:00
Reid Spencer
86ac2dcda1 Fix seriously broken implementation of GetMagicNumber.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18422 91177308-0d34-0410-b5e6-96231b3b80d8
2004-12-02 09:09:48 +00:00
Reid Spencer
be31d2ad78 * Use low-level unix I/O interface since we're on Unix.
* Don't use variable length arrays (replaced with alloca)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17901 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-16 17:14:08 +00:00
Reid Spencer
b608a81a18 Per code review:
* Clean up the StatusInfo constructor to construct all members and give
  them reasonable values.
* Get rid of the Vector typedef and make the interface to
  getDirectoryContent use a std::set instead of a std::vector so the dir
  content is sorted.
* Make the getStatusInfo method const and not return a useless boolean.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17872 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-16 06:15:19 +00:00
Reid Spencer
2fbf978cb7 Implement functionality suggested from code review: getStatusInfo should
returnn false if the file doesn't exist rather than throw ane exception.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17809 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-14 23:30:38 +00:00
Reid Spencer
eaf181550a * Implement getDirectoryContents * Implement getStatusInfo * Implement setStatusInfo * Implement renameFile
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17780 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-14 22:08:36 +00:00
Reid Spencer
9195f37c5f * Implement getStatusInfo for getting stat(2) like information
* Implement createTemporaryFile for mkstemp(3) functionality
* Fix isBytecodeFile to accept llvc magic # (compressed) as bytecode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17654 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-09 20:26:31 +00:00
Reid Spencer
07adb2836b Stop propagating method names that violate the coding standard
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17498 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-05 22:15:36 +00:00
Reid Spencer
622e220ca7 Get rid of file descriptor leak in create_file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16395 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-18 19:25:11 +00:00
Reid Spencer
0cc2d0a1b8 Allow "bc" as suffix for bytecode files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16381 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-16 16:36:10 +00:00
Reid Spencer
74e7261e90 Implement the GetLibraryPath function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16323 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-14 00:16:39 +00:00
Reid Spencer
1b554b4583 Implemented support for detecting file types by magic number, stripping
path and suffix to leave basename, and getting the DLL suffix.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16289 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-11 04:55:08 +00:00
Reid Spencer
551ccae044 Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-01 22:55:40 +00:00
Reid Spencer
f634f46350 Move the GetTemporaryDirectory function from "generic Unix" to platform
specific.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16119 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-30 21:46:55 +00:00
Reid Spencer
8e66595512 Revise the design of the Path concept per peer review. Too many changes to
note individually but these essence of it is to not derive from
std::string, clarify the interface, and provide better documentation.
There is now also (untested) implementations for AIX, Darwin, and SunOS.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16078 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-29 05:24:01 +00:00
Reid Spencer
b89a2237ea Initial implementation of the Path operating system concept.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16048 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-25 06:20:07 +00:00