llvm.org GIT mirror llvm / 1fce091
Path::get -> Path::toString git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18785 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 14 years ago
21 changed file(s) with 141 addition(s) and 123 deletion(s). Raw diff Collapse all Expand all
321321 /// by other software.
322322 /// @returns std::string containing the path name.
323323 /// @brief Returns the path as a std::string.
324 std::string get() const { return path; }
324 std::string toString() const { return path; }
325325
326326 /// This function returns the last component of the path name. If the
327327 /// isDirectory() function would return true then this returns the name
465465 /// @brief Create the directory this Path refers to.
466466 bool createDirectory( bool create_parents = false );
467467
468 /// This method attempts to create a file in the file system with the same
468 /// This method attempts to create a file in the file system with the same
469469 /// name as the Path object. The intermediate directories must all exist
470470 /// at the time this method is called. Use createDirectories to
471471 /// accomplish that. The created file will be empty upon return from this
499499 /// @brief Removes the file or directory from the filesystem.
500500 bool destroyDirectory( bool destroy_contents = false );
501501
502 /// This method attempts to destroy the file named by the last item in the
502 /// This method attempts to destroy the file named by the last item in the
503503 /// Path name.
504504 /// @returns false if the Path does not refer to a file, true otherwise.
505505 /// @throws std::string if there is an error.
2525
2626 // If it has a long filename, include the name length
2727 if (hasLongFilename())
28 result += path.get().length() + 1;
28 result += path.toString().length() + 1;
2929
3030 // If its now odd lengthed, include the padding byte
3131 if (result % 2 != 0 )
6565 path = newFile;
6666
6767 // SVR4 symbol tables have an empty name
68 if (path.get() == ARFILE_SVR4_SYMTAB_NAME)
68 if (path.toString() == ARFILE_SVR4_SYMTAB_NAME)
6969 flags |= SVR4SymbolTableFlag;
7070 else
7171 flags &= ~SVR4SymbolTableFlag;
7272
7373 // BSD4.4 symbol tables have a special name
74 if (path.get() == ARFILE_BSD4_SYMTAB_NAME)
74 if (path.toString() == ARFILE_BSD4_SYMTAB_NAME)
7575 flags |= BSD4SymbolTableFlag;
7676 else
7777 flags &= ~BSD4SymbolTableFlag;
7878
7979 // LLVM symbol tables have a very specific name
80 if (path.get() == ARFILE_LLVM_SYMTAB_NAME)
80 if (path.toString() == ARFILE_LLVM_SYMTAB_NAME)
8181 flags |= LLVMSymbolTableFlag;
8282 else
8383 flags &= ~LLVMSymbolTableFlag;
8484
8585 // String table name
86 if (path.get() == ARFILE_STRTAB_NAME)
86 if (path.toString() == ARFILE_STRTAB_NAME)
8787 flags |= StringTableFlag;
8888 else
8989 flags &= ~StringTableFlag;
9090
9191 // If it has a slash then it has a path
92 bool hasSlash = path.get().find('/') != std::string::npos;
92 bool hasSlash = path.toString().find('/') != std::string::npos;
9393 if (hasSlash)
9494 flags |= HasPathFlag;
9595 else
9696 flags &= ~HasPathFlag;
9797
9898 // If it has a slash or its over 15 chars then its a long filename format
99 if (hasSlash || path.get().length() > 15)
99 if (hasSlash || path.toString().length() > 15)
100100 flags |= HasLongFilenameFlag;
101101 else
102102 flags &= ~HasLongFilenameFlag;
294294
295295 for (iterator I=begin(), E=end(); I != E; ++I) {
296296 if (I->isBytecode() || I->isCompressedBytecode()) {
297 std::string FullMemberName = archPath.get() +
298 "(" + I->getPath().get() + ")";
297 std::string FullMemberName = archPath.toString() +
298 "(" + I->getPath().toString() + ")";
299299 Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
300300 I->getSize(), FullMemberName, ErrMessage);
301301 if (!M)
406406 ArchiveMember* mbr = parseMemberHeader(modptr, base + mapfile->size());
407407
408408 // Now, load the bytecode module to get the ModuleProvider
409 std::string FullMemberName = archPath.get() + "(" +
410 mbr->getPath().get() + ")";
409 std::string FullMemberName = archPath.toString() + "(" +
410 mbr->getPath().toString() + ")";
411411 ModuleProvider* mp = getBytecodeBufferModuleProvider(
412412 (const unsigned char*) mbr->getData(), mbr->getSize(),
413413 FullMemberName, 0);
445445 if (mbr->isBytecode() || mbr->isCompressedBytecode()) {
446446 // Get the symbols
447447 std::vector symbols;
448 std::string FullMemberName = archPath.get() + "(" +
449 mbr->getPath().get() + ")";
448 std::string FullMemberName = archPath.toString() + "(" +
449 mbr->getPath().toString() + ")";
450450 ModuleProvider* MP = GetBytecodeSymbols((const unsigned char*)At,
451451 mbr->getSize(), FullMemberName, symbols);
452452
461461 modules.insert(std::make_pair(offset, std::make_pair(MP, mbr)));
462462 } else {
463463 throw std::string("Can't parse bytecode member: ") +
464 mbr->getPath().get();
464 mbr->getPath().toString();
465465 }
466466 }
467467
9393 memcpy(hdr.date,buffer,12);
9494
9595 // Get rid of trailing blanks in the name
96 std::string mbrPath = mbr.getPath().get();
96 std::string mbrPath = mbr.getPath().toString();
9797 size_t mbrLen = mbrPath.length();
9898 while (mbrLen > 0 && mbrPath[mbrLen-1] == ' ') {
9999 mbrPath.erase(mbrLen-1,1);
161161 mbr->path.getStatusInfo(mbr->info);
162162
163163 unsigned flags = 0;
164 bool hasSlash = filePath.get().find('/') != std::string::npos;
164 bool hasSlash = filePath.toString().find('/') != std::string::npos;
165165 if (hasSlash)
166166 flags |= ArchiveMember::HasPathFlag;
167 if (hasSlash || filePath.get().length() > 15)
167 if (hasSlash || filePath.toString().length() > 15)
168168 flags |= ArchiveMember::HasLongFilenameFlag;
169169 std::string magic;
170170 mbr->path.getMagicNumber(magic,4);
211211 if (CreateSymbolTable &&
212212 (member.isBytecode() || member.isCompressedBytecode())) {
213213 std::vector symbols;
214 std::string FullMemberName = archPath.get() + "(" + member.getPath().get()
214 std::string FullMemberName = archPath.toString() + "(" +
215 member.getPath().toString()
215216 + ")";
216217 ModuleProvider* MP = GetBytecodeSymbols(
217218 (const unsigned char*)data,fSize,FullMemberName, symbols);
234235 delete MP;
235236 } else {
236237 throw std::string("Can't parse bytecode member: ") +
237 member.getPath().get();
238 member.getPath().toString();
238239 }
239240 }
240241
280281
281282 // Write the long filename if its long
282283 if (writeLongName) {
283 ARFile.write(member.getPath().get().data(),member.getPath().get().length());
284 ARFile.write(member.getPath().toString().data(),
285 member.getPath().toString().length());
284286 }
285287
286288 // Make sure we write the compressed bytecode magic number if we should.
377379
378380 // Check for errors opening or creating archive file.
379381 if ( !ArchiveFile.is_open() || ArchiveFile.bad() ) {
380 throw std::string("Error opening archive file: ") + archPath.get();
382 throw std::string("Error opening archive file: ") + archPath.toString();
381383 }
382384
383385 // If we're creating a symbol table, reset it now
413415 // Open the final file to write and check it.
414416 std::ofstream FinalFile(archPath.c_str());
415417 if ( !FinalFile.is_open() || FinalFile.bad() ) {
416 throw std::string("Error opening archive file: ") + archPath.get();
418 throw std::string("Error opening archive file: ") + archPath.toString();
417419 }
418420
419421 // Write the file magic number
2525
2626 // If it has a long filename, include the name length
2727 if (hasLongFilename())
28 result += path.get().length() + 1;
28 result += path.toString().length() + 1;
2929
3030 // If its now odd lengthed, include the padding byte
3131 if (result % 2 != 0 )
6565 path = newFile;
6666
6767 // SVR4 symbol tables have an empty name
68 if (path.get() == ARFILE_SVR4_SYMTAB_NAME)
68 if (path.toString() == ARFILE_SVR4_SYMTAB_NAME)
6969 flags |= SVR4SymbolTableFlag;
7070 else
7171 flags &= ~SVR4SymbolTableFlag;
7272
7373 // BSD4.4 symbol tables have a special name
74 if (path.get() == ARFILE_BSD4_SYMTAB_NAME)
74 if (path.toString() == ARFILE_BSD4_SYMTAB_NAME)
7575 flags |= BSD4SymbolTableFlag;
7676 else
7777 flags &= ~BSD4SymbolTableFlag;
7878
7979 // LLVM symbol tables have a very specific name
80 if (path.get() == ARFILE_LLVM_SYMTAB_NAME)
80 if (path.toString() == ARFILE_LLVM_SYMTAB_NAME)
8181 flags |= LLVMSymbolTableFlag;
8282 else
8383 flags &= ~LLVMSymbolTableFlag;
8484
8585 // String table name
86 if (path.get() == ARFILE_STRTAB_NAME)
86 if (path.toString() == ARFILE_STRTAB_NAME)
8787 flags |= StringTableFlag;
8888 else
8989 flags &= ~StringTableFlag;
9090
9191 // If it has a slash then it has a path
92 bool hasSlash = path.get().find('/') != std::string::npos;
92 bool hasSlash = path.toString().find('/') != std::string::npos;
9393 if (hasSlash)
9494 flags |= HasPathFlag;
9595 else
9696 flags &= ~HasPathFlag;
9797
9898 // If it has a slash or its over 15 chars then its a long filename format
99 if (hasSlash || path.get().length() > 15)
99 if (hasSlash || path.toString().length() > 15)
100100 flags |= HasLongFilenameFlag;
101101 else
102102 flags &= ~HasLongFilenameFlag;
294294
295295 for (iterator I=begin(), E=end(); I != E; ++I) {
296296 if (I->isBytecode() || I->isCompressedBytecode()) {
297 std::string FullMemberName = archPath.get() +
298 "(" + I->getPath().get() + ")";
297 std::string FullMemberName = archPath.toString() +
298 "(" + I->getPath().toString() + ")";
299299 Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
300300 I->getSize(), FullMemberName, ErrMessage);
301301 if (!M)
406406 ArchiveMember* mbr = parseMemberHeader(modptr, base + mapfile->size());
407407
408408 // Now, load the bytecode module to get the ModuleProvider
409 std::string FullMemberName = archPath.get() + "(" +
410 mbr->getPath().get() + ")";
409 std::string FullMemberName = archPath.toString() + "(" +
410 mbr->getPath().toString() + ")";
411411 ModuleProvider* mp = getBytecodeBufferModuleProvider(
412412 (const unsigned char*) mbr->getData(), mbr->getSize(),
413413 FullMemberName, 0);
445445 if (mbr->isBytecode() || mbr->isCompressedBytecode()) {
446446 // Get the symbols
447447 std::vector symbols;
448 std::string FullMemberName = archPath.get() + "(" +
449 mbr->getPath().get() + ")";
448 std::string FullMemberName = archPath.toString() + "(" +
449 mbr->getPath().toString() + ")";
450450 ModuleProvider* MP = GetBytecodeSymbols((const unsigned char*)At,
451451 mbr->getSize(), FullMemberName, symbols);
452452
461461 modules.insert(std::make_pair(offset, std::make_pair(MP, mbr)));
462462 } else {
463463 throw std::string("Can't parse bytecode member: ") +
464 mbr->getPath().get();
464 mbr->getPath().toString();
465465 }
466466 }
467467
9393 memcpy(hdr.date,buffer,12);
9494
9595 // Get rid of trailing blanks in the name
96 std::string mbrPath = mbr.getPath().get();
96 std::string mbrPath = mbr.getPath().toString();
9797 size_t mbrLen = mbrPath.length();
9898 while (mbrLen > 0 && mbrPath[mbrLen-1] == ' ') {
9999 mbrPath.erase(mbrLen-1,1);
161161 mbr->path.getStatusInfo(mbr->info);
162162
163163 unsigned flags = 0;
164 bool hasSlash = filePath.get().find('/') != std::string::npos;
164 bool hasSlash = filePath.toString().find('/') != std::string::npos;
165165 if (hasSlash)
166166 flags |= ArchiveMember::HasPathFlag;
167 if (hasSlash || filePath.get().length() > 15)
167 if (hasSlash || filePath.toString().length() > 15)
168168 flags |= ArchiveMember::HasLongFilenameFlag;
169169 std::string magic;
170170 mbr->path.getMagicNumber(magic,4);
211211 if (CreateSymbolTable &&
212212 (member.isBytecode() || member.isCompressedBytecode())) {
213213 std::vector symbols;
214 std::string FullMemberName = archPath.get() + "(" + member.getPath().get()
214 std::string FullMemberName = archPath.toString() + "(" +
215 member.getPath().toString()
215216 + ")";
216217 ModuleProvider* MP = GetBytecodeSymbols(
217218 (const unsigned char*)data,fSize,FullMemberName, symbols);
234235 delete MP;
235236 } else {
236237 throw std::string("Can't parse bytecode member: ") +
237 member.getPath().get();
238 member.getPath().toString();
238239 }
239240 }
240241
280281
281282 // Write the long filename if its long
282283 if (writeLongName) {
283 ARFile.write(member.getPath().get().data(),member.getPath().get().length());
284 ARFile.write(member.getPath().toString().data(),
285 member.getPath().toString().length());
284286 }
285287
286288 // Make sure we write the compressed bytecode magic number if we should.
377379
378380 // Check for errors opening or creating archive file.
379381 if ( !ArchiveFile.is_open() || ArchiveFile.bad() ) {
380 throw std::string("Error opening archive file: ") + archPath.get();
382 throw std::string("Error opening archive file: ") + archPath.toString();
381383 }
382384
383385 // If we're creating a symbol table, reset it now
413415 // Open the final file to write and check it.
414416 std::ofstream FinalFile(archPath.c_str());
415417 if ( !FinalFile.is_open() || FinalFile.bad() ) {
416 throw std::string("Error opening archive file: ") + archPath.get();
418 throw std::string("Error opening archive file: ") + archPath.toString();
417419 }
418420
419421 // Write the file magic number
373373 bool llvm::GetBytecodeSymbols(const sys::Path& fName,
374374 std::vector& symbols) {
375375 try {
376 std::auto_ptr AMP( getBytecodeModuleProvider(fName.get()));
376 std::auto_ptr AMP(
377 getBytecodeModuleProvider(fName.toString()));
377378
378379 // Get the module from the provider
379380 Module* M = AMP->materializeModule();
4343 if (info_->fd_ < 0) {
4444 delete info_;
4545 info_ = 0;
46 ThrowErrno(std::string("Can't open file: ") + path_.get());
46 ThrowErrno(std::string("Can't open file: ") + path_.toString());
4747 }
4848 struct stat sbuf;
4949 if(::fstat(info_->fd_, &info_->sbuf_) < 0) {
5050 ::close(info_->fd_);
5151 delete info_;
5252 info_ = 0;
53 ThrowErrno(std::string("Can't stat file: ") + path_.get());
53 ThrowErrno(std::string("Can't stat file: ") + path_.toString());
5454 }
5555 } else {
56 throw std::string("Can't open file: ") + path_.get();
56 throw std::string("Can't open file: ") + path_.toString();
5757 }
5858 }
5959
102102
103103 base_ = ::mmap(0, map_size, prot, flags, info_->fd_, 0);
104104 if (base_ == MAP_FAILED)
105 ThrowErrno(std::string("Can't map file:") + path_.get());
105 ThrowErrno(std::string("Can't map file:") + path_.toString());
106106 }
107107 return base_;
108108 }
4343 if (info_->fd_ < 0) {
4444 delete info_;
4545 info_ = 0;
46 ThrowErrno(std::string("Can't open file: ") + path_.get());
46 ThrowErrno(std::string("Can't open file: ") + path_.toString());
4747 }
4848 struct stat sbuf;
4949 if(::fstat(info_->fd_, &info_->sbuf_) < 0) {
5050 ::close(info_->fd_);
5151 delete info_;
5252 info_ = 0;
53 ThrowErrno(std::string("Can't stat file: ") + path_.get());
53 ThrowErrno(std::string("Can't stat file: ") + path_.toString());
5454 }
5555 } else {
56 throw std::string("Can't open file: ") + path_.get();
56 throw std::string("Can't open file: ") + path_.toString();
5757 }
5858 }
5959
102102
103103 base_ = ::mmap(0, map_size, prot, flags, info_->fd_, 0);
104104 if (base_ == MAP_FAILED)
105 ThrowErrno(std::string("Can't map file:") + path_.get());
105 ThrowErrno(std::string("Can't map file:") + path_.toString());
106106 }
107107 return base_;
108108 }
2020 #include "Unix.h"
2121 #include
2222 #include
23 #include
2423 #include
2524 #include
2625
191190 Path::isBytecodeFile() const {
192191 char buffer[ 4];
193192 buffer[0] = 0;
194 std::ifstream f(path.c_str());
195 f.read(buffer, 4);
196 if (f.bad())
197 ThrowErrno("can't read file signature");
193 int fd = ::open(path.c_str(),O_RDONLY);
194 if (fd < 0)
195 return false;
196 ssize_t bytes_read = ::read(fd, buffer, 4);
197 ::close(fd);
198 if (4 != bytes_read)
199 return false;
198200
199201 return (buffer[0] == 'l' && buffer[1] == 'l' && buffer[2] == 'v' &&
200202 (buffer[3] == 'c' || buffer[3] == 'm'));
521523 Path::renameFile(const Path& newName) {
522524 if (!isFile()) return false;
523525 if (0 != rename(path.c_str(), newName.c_str()))
524 ThrowErrno(std::string("can't rename ") + path + " as " + newName.get());
526 ThrowErrno(std::string("can't rename ") + path + " as " +
527 newName.toString());
525528 return true;
526529 }
527530
2020 #include "Unix.h"
2121 #include
2222 #include
23 #include
2423 #include
2524 #include
2625
191190 Path::isBytecodeFile() const {
192191 char buffer[ 4];
193192 buffer[0] = 0;
194 std::ifstream f(path.c_str());
195 f.read(buffer, 4);
196 if (f.bad())
197 ThrowErrno("can't read file signature");
193 int fd = ::open(path.c_str(),O_RDONLY);
194 if (fd < 0)
195 return false;
196 ssize_t bytes_read = ::read(fd, buffer, 4);
197 ::close(fd);
198 if (4 != bytes_read)
199 return false;
198200
199201 return (buffer[0] == 'l' && buffer[1] == 'l' && buffer[2] == 'v' &&
200202 (buffer[3] == 'c' || buffer[3] == 'm'));
521523 Path::renameFile(const Path& newName) {
522524 if (!isFile()) return false;
523525 if (0 != rename(path.c_str(), newName.c_str()))
524 ThrowErrno(std::string("can't rename ") + path + " as " + newName.get());
526 ThrowErrno(std::string("can't rename ") + path + " as " +
527 newName.toString());
525528 return true;
526529 }
527530
8080 Program::ExecuteAndWait(const Path& path,
8181 const std::vector& args) {
8282 if (!path.executable())
83 throw path.get() + " is not executable";
83 throw path.toString() + " is not executable";
8484
8585 #ifdef HAVE_SYS_WAIT_H
8686 // Create local versions of the parameters that can be passed into execve()
9797 switch (fork()) {
9898 // An error occured: Return to the caller.
9999 case -1:
100 ThrowErrno(std::string("Couldn't execute program '") + path.get() + "'");
100 ThrowErrno(std::string("Couldn't execute program '") + path.toString() +
101 "'");
101102 break;
102103
103104 // Child process: Execute the program.
115116 // Parent process: Wait for the child process to terminate.
116117 int status;
117118 if ((::wait (&status)) == -1)
118 ThrowErrno(std::string("Failed waiting for program '") + path.get() + "'");
119 ThrowErrno(std::string("Failed waiting for program '") + path.toString()
120 + "'");
119121
120122 // If the program exited normally with a zero exit status, return success!
121123 if (WIFEXITED (status))
122124 return WEXITSTATUS(status);
123125 else if (WIFSIGNALED(status))
124 throw std::string("Program '") + path.get() + "' received terminating signal.";
126 throw std::string("Program '") + path.toString() +
127 "' received terminating signal.";
125128 else
126129 return 0;
127130
8080 Program::ExecuteAndWait(const Path& path,
8181 const std::vector& args) {
8282 if (!path.executable())
83 throw path.get() + " is not executable";
83 throw path.toString() + " is not executable";
8484
8585 #ifdef HAVE_SYS_WAIT_H
8686 // Create local versions of the parameters that can be passed into execve()
9797 switch (fork()) {
9898 // An error occured: Return to the caller.
9999 case -1:
100 ThrowErrno(std::string("Couldn't execute program '") + path.get() + "'");
100 ThrowErrno(std::string("Couldn't execute program '") + path.toString() +
101 "'");
101102 break;
102103
103104 // Child process: Execute the program.
115116 // Parent process: Wait for the child process to terminate.
116117 int status;
117118 if ((::wait (&status)) == -1)
118 ThrowErrno(std::string("Failed waiting for program '") + path.get() + "'");
119 ThrowErrno(std::string("Failed waiting for program '") + path.toString()
120 + "'");
119121
120122 // If the program exited normally with a zero exit status, return success!
121123 if (WIFEXITED (status))
122124 return WEXITSTATUS(status);
123125 else if (WIFSIGNALED(status))
124 throw std::string("Program '") + path.get() + "' received terminating signal.";
126 throw std::string("Program '") + path.toString() +
127 "' received terminating signal.";
125128 else
126129 return 0;
127130
137137 if (FilesToRemove == 0)
138138 FilesToRemove = new std::vector;
139139
140 FilesToRemove->push_back(Filename.get());
140 FilesToRemove->push_back(Filename.toString());
141141
142142 std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
143143 std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
137137 if (FilesToRemove == 0)
138138 FilesToRemove = new std::vector;
139139
140 FilesToRemove->push_back(Filename.get());
140 FilesToRemove->push_back(Filename.toString());
141141
142142 std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
143143 std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
344344 continue;
345345
346346 if (Verbose)
347 std::cout << "Printing " << I->getPath().get() << "\n";
347 std::cout << "Printing " << I->getPath().toString() << "\n";
348348
349349 if (I->isCompressedBytecode())
350350 Compressor::decompressToStream(data+4,I->getSize()-4,std::cout);
408408 std::cout << " " << std::setw(8) << I->getSize();
409409 std::cout << " " << std::setw(20) <<
410410 I->getModTime().toString().substr(4);
411 std::cout << " " << I->getPath().get() << "\n";
411 std::cout << " " << I->getPath().toString() << "\n";
412412 } else {
413 std::cout << I->getPath().get() << "\n";
413 std::cout << I->getPath().toString() << "\n";
414414 }
415415 }
416416 }
504504 if (AddBefore || InsertBefore || AddAfter) {
505505 for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end();
506506 I != E; ++I ) {
507 if (RelPos == I->getPath().get()) {
507 if (RelPos == I->getPath().toString()) {
508508 if (AddAfter) {
509509 moveto_spot = I;
510510 moveto_spot++;
581581 std::set::iterator found = remaining.end();
582582 for (std::set::iterator RI = remaining.begin(),
583583 RE = remaining.end(); RI != RE; ++RI ) {
584 std::string compare(RI->get());
584 std::string compare(RI->toString());
585585 if (TruncateNames && compare.length() > 15) {
586586 const char* nm = compare.c_str();
587587 unsigned len = compare.length();
594594 len = 15;
595595 compare.assign(nm,len);
596596 }
597 if (compare == I->getPath().get()) {
597 if (compare == I->getPath().toString()) {
598598 found = RI;
599599 break;
600600 }
621621 }
622622
623623 // Determine if this is the place where we should insert
624 if ((AddBefore || InsertBefore) && (RelPos == I->getPath().get()))
624 if ((AddBefore || InsertBefore) && (RelPos == I->getPath().toString()))
625625 insert_spot = I;
626 else if (AddAfter && (RelPos == I->getPath().get())) {
626 else if (AddAfter && (RelPos == I->getPath().toString())) {
627627 insert_spot = I;
628628 insert_spot++;
629629 }
674674 if (!ArchivePath.exists()) {
675675 // Produce a warning if we should and we're creating the archive
676676 if (!Create)
677 std::cerr << argv[0] << ": creating " << ArchivePath.get() << "\n";
677 std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n";
678678 TheArchive = Archive::CreateEmpty(ArchivePath);
679679 } else {
680680 TheArchive = Archive::OpenAndLoad(ArchivePath);
5757 std::string ErrorMessage;
5858 if (Filename.exists()) {
5959 if (Verbose) std::cerr << "Loading '" << Filename.c_str() << "'\n";
60 Module* Result = ParseBytecodeFile(Filename.get(), &ErrorMessage);
60 Module* Result = ParseBytecodeFile(Filename.toString(), &ErrorMessage);
6161 if (Result) return std::auto_ptr(Result); // Load successful!
6262
6363 if (Verbose) {
189189 if (TempDir.isDirectory() && TempDir.writable())
190190 TempDir.destroyDirectory(/*remove_contents=*/true);
191191 } else {
192 std::cout << "Temporary files are in " << TempDir.get() << "\n";
192 std::cout << "Temporary files are in " << TempDir.toString() << "\n";
193193 }
194194 }
195195
269269 break;
270270 case 'i':
271271 if (*PI == "%in%") {
272 action->args.push_back(input.get());
272 action->args.push_back(input.toString());
273273 } else if (*PI == "%incls%") {
274274 PathVector::iterator I = IncludePaths.begin();
275275 PathVector::iterator E = IncludePaths.end();
276276 while (I != E) {
277 action->args.push_back( std::string("-I") + I->get() );
277 action->args.push_back( std::string("-I") + I->toString() );
278278 ++I;
279279 }
280280 } else
285285 PathVector::iterator I = LibraryPaths.begin();
286286 PathVector::iterator E = LibraryPaths.end();
287287 while (I != E) {
288 action->args.push_back( std::string("-L") + I->get() );
288 action->args.push_back( std::string("-L") + I->toString() );
289289 ++I;
290290 }
291291 } else
293293 break;
294294 case 'o':
295295 if (*PI == "%out%") {
296 action->args.push_back(output.get());
296 action->args.push_back(output.toString());
297297 } else if (*PI == "%opt%") {
298298 if (!isSet(EMIT_RAW_FLAG)) {
299299 if (cd->opts.size() > static_cast(optLevel) &&
357357 if (PI->length()>1 && (*PI)[0] == '%' &&
358358 (*PI)[PI->length()-1] == '%') {
359359 throw std::string("Invalid substitution token: '") + *PI +
360 "' for command '" + pat->program.get() + "'";
360 "' for command '" + pat->program.toString() + "'";
361361 } else if (!PI->empty()) {
362362 // It's not a legal substitution, just pass it through
363363 action->args.push_back(*PI);
380380 WriteAction(action);
381381 if (!isSet(DRY_RUN_FLAG)) {
382382 sys::Path progpath = sys::Program::FindProgramByName(
383 action->program.get());
383 action->program.toString());
384384 if (progpath.isEmpty())
385 throw std::string("Can't find program '"+action->program.get()+"'");
385 throw std::string("Can't find program '" +
386 action->program.toString()+"'");
386387 else if (progpath.executable())
387388 action->program = progpath;
388389 else
389 throw std::string("Program '"+action->program.get()+
390 throw std::string("Program '"+action->program.toString()+
390391 "' is not executable.");
391392
392393 // Invoke the program
393394 if (isSet(TIME_ACTIONS_FLAG)) {
394 Timer timer(action->program.get());
395 Timer timer(action->program.toString());
395396 timer.startTimer();
396397 int resultCode =
397398 sys::Program::ExecuteAndWait(action->program,action->args);
417418 return fullpath;
418419 for (PathVector::iterator PI = LibraryPaths.begin(),
419420 PE = LibraryPaths.end(); PI != PE; ++PI) {
420 fullpath.setDirectory(PI->get());
421 fullpath.setDirectory(PI->toString());
421422 fullpath.appendFile(link_item);
422423 if (fullpath.readable())
423424 return fullpath;
461462 if (!link_item.readable()) {
462463 // look for the library using the -L arguments specified
463464 // on the command line.
464 fullpath = GetPathForLinkageItem(link_item.get());
465 fullpath = GetPathForLinkageItem(link_item.toString());
465466
466467 // If we didn't find the file in any of the library search paths
467468 // we have to bail. No where else to look.
468469 if (fullpath.isEmpty()) {
469470 err =
470 std::string("Can't find linkage item '") + link_item.get() + "'";
471 std::string("Can't find linkage item '") + link_item.toString() + "'";
471472 return false;
472473 }
473474 } else {
481482 if (fullpath.isBytecodeFile()) {
482483 // Process the dependent libraries recursively
483484 Module::LibraryListType modlibs;
484 if (GetBytecodeDependentLibraries(fullpath.get(),modlibs)) {
485 if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs)) {
485486 // Traverse the dependent libraries list
486487 Module::lib_iterator LI = modlibs.begin();
487488 Module::lib_iterator LE = modlibs.end();
490491 if (err.empty()) {
491492 err = std::string("Library '") + *LI +
492493 "' is not valid for linking but is required by file '" +
493 fullpath.get() + "'";
494 fullpath.toString() + "'";
494495 } else {
495 err += " which is required by file '" + fullpath.get() + "'";
496 err += " which is required by file '" + fullpath.toString() + "'";
496497 }
497498 return false;
498499 }
501502 } else if (err.empty()) {
502503 err = std::string(
503504 "The dependent libraries could not be extracted from '") +
504 fullpath.get();
505 fullpath.toString();
505506 return false;
506507 }
507508 }
528529 std::cerr << "OutputMachine = " << machine << "\n";
529530 InputList::const_iterator I = InpList.begin();
530531 while ( I != InpList.end() ) {
531 std::cerr << "Input: " << I->first.get() << "(" << I->second
532 std::cerr << "Input: " << I->first.toString() << "(" << I->second
532533 << ")\n";
533534 ++I;
534535 }
535 std::cerr << "Output: " << Output.get() << "\n";
536 std::cerr << "Output: " << Output.toString() << "\n";
536537 }
537538
538539 // If there's no input, we're done.
576577 "Pre-compiled objects found but linking not requested");
577578 }
578579 if (ftype.empty())
579 LibFiles.push_back(I->first.get());
580 LibFiles.push_back(I->first.toString());
580581 else
581582 LinkageItems.insert(I->first);
582583 continue; // short circuit remainder of loop
658659 /// We need to translate it to bytecode
659660 Action* action = new Action();
660661 action->program.setFile("llvm-as");
661 action->args.push_back(InFile.get());
662 action->args.push_back(InFile.toString());
662663 action->args.push_back("-o");
663664 InFile.appendSuffix("bc");
664 action->args.push_back(InFile.get());
665 action->args.push_back(InFile.toString());
665666 actions.push_back(action);
666667 }
667668 }
700701 /// We need to translate it to bytecode with llvm-as
701702 Action* action = new Action();
702703 action->program.setFile("llvm-as");
703 action->args.push_back(InFile.get());
704 action->args.push_back(InFile.toString());
704705 action->args.push_back("-f");
705706 action->args.push_back("-o");
706707 InFile.appendSuffix("bc");
707 action->args.push_back(InFile.get());
708 action->args.push_back(InFile.toString());
708709 actions.push_back(action);
709710 }
710711 }
729730 if (isSet(EMIT_NATIVE_FLAG)) {
730731 // Use llc to get the native assembly file
731732 action->program.setFile("llc");
732 action->args.push_back(InFile.get());
733 action->args.push_back(InFile.toString());
733734 action->args.push_back("-f");
734735 action->args.push_back("-o");
735736 if (Output.isEmpty()) {
736737 OutFile.appendSuffix("o");
737 action->args.push_back(OutFile.get());
738 action->args.push_back(OutFile.toString());
738739 } else {
739 action->args.push_back(Output.get());
740 action->args.push_back(Output.toString());
740741 }
741742 actions.push_back(action);
742743 } else {
743744 // Just convert back to llvm assembly with llvm-dis
744745 action->program.setFile("llvm-dis");
745 action->args.push_back(InFile.get());
746 action->args.push_back(InFile.toString());
746747 action->args.push_back("-f");
747748 action->args.push_back("-o");
748749 if (Output.isEmpty()) {
749750 OutFile.appendSuffix("ll");
750 action->args.push_back(OutFile.get());
751 action->args.push_back(OutFile.toString());
751752 } else {
752 action->args.push_back(Output.get());
753 action->args.push_back(Output.toString());
753754 }
754755 }
755756
811812 // -l arguments specified.
812813 for (PathVector::const_iterator I=LinkageItems.begin(),
813814 E=LinkageItems.end(); I != E; ++I )
814 link->args.push_back(I->get());
815 link->args.push_back(I->toString());
815816
816817 // Add in all the libraries we found.
817818 for (std::vector::const_iterator I=LibFiles.begin(),
821822 // Add in all the library paths to the command line
822823 for (PathVector::const_iterator I=LibraryPaths.begin(),
823824 E=LibraryPaths.end(); I != E; ++I)
824 link->args.push_back( std::string("-L") + I->get());
825 link->args.push_back( std::string("-L") + I->toString());
825826
826827 // Add in the additional linker arguments requested
827828 for (StringVector::const_iterator I=AdditionalArgs[LINKING].begin(),
846847
847848 // Add in mandatory flags
848849 link->args.push_back("-o");
849 link->args.push_back(Output.get());
850 link->args.push_back(Output.toString());
850851
851852 // Execute the link
852853 if (!DoAction(link))
581581 throw std::string("Configuration file for '") + ftype +
582582 "' is not available.";
583583 }
584 FileInputProvider fip( confFile.get() );
584 FileInputProvider fip( confFile.toString() );
585585 if (!fip.okay()) {
586586 throw std::string("Configuration file for '") + ftype +
587587 "' is not available.";
240240 void handleTerminatingOptions(CompilerDriver* CD) {
241241 if (!PrintFileName.empty()) {
242242 sys::Path path = CD->GetPathForLinkageItem(PrintFileName,false);
243 std::string p = path.get();
243 std::string p = path.toString();
244244 if (p.empty())
245245 std::cout << "Can't locate '" << PrintFileName << "'.\n";
246246 else