-// LoadFile - Read the specified bytecode file in and return it. This routine
-// searches the link path for the specified file to try to find it...
-//
-static inline std::auto_ptr<Module> LoadFile(const string &FN) {
- string Filename = FN;
- string ErrorMessage;
-
- unsigned NextLibPathIdx = 0;
- bool FoundAFile = false;
-
- while (1) {
- if (Verbose) cerr << "Loading '" << Filename << "'\n";
- if (FileExists(Filename)) FoundAFile = true;
- Module *Result = ParseBytecodeFile(Filename, &ErrorMessage);
- if (Result) return std::auto_ptr<Module>(Result); // Load successful!
-
- if (Verbose) {
- cerr << "Error opening bytecode file: '" << Filename << "'";
- if (ErrorMessage.size()) cerr << ": " << ErrorMessage;
- cerr << endl;
- }
-
- if (NextLibPathIdx == LibPaths.size()) break;
- Filename = LibPaths[NextLibPathIdx++] + "/" + FN;
- }