这篇教程C++ FileNotFoundException函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FileNotFoundException函数的典型用法代码示例。如果您正苦于以下问题:C++ FileNotFoundException函数的具体用法?C++ FileNotFoundException怎么用?C++ FileNotFoundException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FileNotFoundException函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: MergeStreamsvoid MergeStreams(FileInputStream * in1, FileInputStream * in2, char * outfile) {FileOutputStream * outStream = NULL;try { int nbytes; char buffer[1]; outStream = new FileOutputStream(outfile); while ((nbytes = (in1->read(buffer, 1)) != -1)) { outStream->write(buffer, nbytes); } while ((nbytes = (in2->read(buffer, 1)) != -1)) { outStream->write(buffer, nbytes); } delete outStream; }catch (IOException & err) { err.Display(); cout<<"Deleting dynamic outStream object"<<endl; delete outStream; throw FileNotFoundException(outfile); }catch (Xception & err) { err.Display(); cout<<"Deleting dynamic FileOutputStream object"<<endl; delete outStream; throw FileNotFoundException(outfile); }}
开发者ID:rortian,项目名称:oldjava,代码行数:30,
示例2: FileNotFoundExceptionint JpegStegoDecoder::Decode(char *infile, char *outfile, bool getMes){ if(!outfile) outfile = "nul"; // test for existing input and output files FILE *fp; if ((fp = fopen(infile, READ_BINARY)) == NULL) { throw FileNotFoundException("File not found/n",infile); } fclose(fp); if ((fp = fopen(outfile, WRITE_BINARY)) == NULL) { throw FileNotFoundException("File not found/n",outfile); } fclose(fp); InitJpegStego(true); int argc = 3; char *argv[3]; char name[]="djpeg"; argv[0]=name; argv[1]=infile; argv[2]=outfile; return main_djpeg(argc, argv, sData);}
开发者ID:KolorKode,项目名称:Stg,代码行数:29,
示例3: poco_assertvoid FileImpl::renameToImpl(const std::string& path){ poco_assert (!_path.empty()); POCO_DESCRIPTOR_STRING(oldNameDsc, _path); POCO_DESCRIPTOR_STRING(newNameDsc, path); int res; if ((res = lib$rename_file(&oldNameDsc, &newNameDsc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) != 1) { switch (res & 0x0FFFFFFF) { case RMS$_FNF: throw FileNotFoundException(_path); case RMS$_DEV: case RMS$_DNF: throw PathNotFoundException(_path); case RMS$_SYN: throw PathSyntaxException(path); case RMS$_RMV: throw FileAccessDeniedException(_path); case RMS$_PRV: throw FileAccessDeniedException("insufficient privileges", _path); default: throw FileException(path); } }}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:28,
示例4: IOException /// <summary>Get fully resolved copy of the path</summary> /// <returns></returns> /// <exception cref="Logic::ComException">COM operation failed</exception> /// <exception cref="Logic::FileNotFoundException">Path not found</exception> /// <exception cref="Logic::IOException">Unable to query properties</exception> Path Path::GetResolved() const { Path resolved; // Resolve path if (!GetFullPathName(c_str(), MAX_PATH, (wchar*)resolved, nullptr)) throw IOException(HERE, L"Unable to resolve path: "+SysErrorString()); // Ensure exists if (!resolved.Exists()) throw FileNotFoundException(HERE, resolved); // Get info SHFILEINFO info; if (!SHGetFileInfo((wchar*)resolved, 0, &info, sizeof(info), SHGFI_ATTRIBUTES)) throw IOException(HERE, L"Unable to retrieve file info: "+SysErrorString()); // Ensure is link if (info.dwAttributes & SFGAO_LINK) { IShellLinkPtr shell(CLSID_ShellLink); IPersistFilePtr file(shell); HRESULT hr; // Load file, resolve link, extract resolved path if (FAILED(hr=file->Load(resolved.c_str(), STGM_READ)) || FAILED(hr=shell->Resolve(nullptr, SLR_NO_UI|SLR_ANY_MATCH)) || FAILED(hr=shell->GetPath((wchar*)resolved, MAX_PATH, nullptr, 0))) throw ComException(HERE, L"Unable to resolve shell link: ", hr); } // Return resolved path return resolved; }
开发者ID:CyberSys,项目名称:X-Studio-2,代码行数:39,
示例5: StripShaderNamestd::pair<std::string, std::string> ShaderManager::FindShaderCode(const std::string& name) const { std::string keyName = StripShaderName(name); std::string fileName = StripShaderName(name, false); // try it in direct source cache auto codeIt = m_codes.find(keyName); if (codeIt != m_codes.end()) { return { keyName, codeIt->second }; } // try it in directories for (const auto& directory : m_directories) { auto filepath = directory / (fileName + ".hlsl"); std::ifstream fs(filepath.c_str()); if (fs.is_open()) { fs.seekg(0, std::ios::end); size_t s = fs.tellg(); fs.seekg(0, std::ios::beg); std::unique_ptr<char[]> content = std::make_unique<char[]>(s + 1); fs.read(content.get(), s); content[s] = '/0'; return { filepath.generic_string(), content.get() }; } } throw FileNotFoundException("Shader was not found.", keyName + "(" + name + " as requested)");}
开发者ID:swordlegend,项目名称:Inline-Engine,代码行数:27,
示例6: templatePathPath TemplateCache::resolvePath(const Path& path) const{ if ( path.isAbsolute() ) return path; for(std::vector<Path>::const_iterator it = _includePaths.begin(); it != _includePaths.end(); ++it) { Path templatePath(*it, path); File templateFile(templatePath); if ( templateFile.exists() ) { if ( _logger ) { poco_trace_f2(*_logger, "%s template file resolved to %s", path.toString(), templatePath.toString()); } return templatePath; } if ( _logger ) { poco_trace_f1(*_logger, "%s doesn't exist", templatePath.toString()); } } throw FileNotFoundException(path.toString());}
开发者ID:12307,项目名称:poco,代码行数:26,
示例7: isvoid CFileContent::load() { ifstream is( realPath_m, ifstream::binary ); if ( !is ) throw FileNotFoundException( userPath_m.c_str(), "" ); is.seekg( 0, is.end ); size_m = (size_t) is.tellg(); is.seekg( 0, is.beg ); char * buf = new char[size_m]; is.read( buf, size_m ); size_m = (size_t) is.tellg(); data_m.insert( data_m.begin(), buf, buf + size_m ); delete[] buf; if ( !is.good() ) throw FileErrorException( userPath_m.c_str() ); is.close(); modificationTime(); creationTime();}
开发者ID:metopa,项目名称:HTTP_Server,代码行数:25,
示例8: GetLastErrorvoid SerialChannelImpl::handleError(const std::string& name){ std::string errorText; DWORD error = GetLastError(); switch (error) { case ERROR_FILE_NOT_FOUND: throw FileNotFoundException(name, getErrorText(errorText)); case ERROR_ACCESS_DENIED: throw FileAccessDeniedException(name, getErrorText(errorText)); case ERROR_ALREADY_EXISTS: case ERROR_FILE_EXISTS: throw FileExistsException(name, getErrorText(errorText)); case ERROR_FILE_READ_ONLY: throw FileReadOnlyException(name, getErrorText(errorText)); case ERROR_CANNOT_MAKE: case ERROR_INVALID_NAME: case ERROR_FILENAME_EXCED_RANGE: throw CreateFileException(name, getErrorText(errorText)); case ERROR_BROKEN_PIPE: case ERROR_INVALID_USER_BUFFER: case ERROR_INSUFFICIENT_BUFFER: throw IOException(name, getErrorText(errorText)); case ERROR_NOT_ENOUGH_MEMORY: throw OutOfMemoryException(name, getErrorText(errorText)); case ERROR_HANDLE_EOF: break; default: throw FileException(name, getErrorText(errorText)); }}
开发者ID:RangelReale,项目名称:sandbox,代码行数:31,
示例9: manifest_offsetArchiveReader::ArchiveReader(const path_t &path, const path_t *encrypted_fso, RsaKeyPair *keypair): manifest_offset(-1), path(path), keypair(keypair){ if (!boost::filesystem::exists(path) || !boost::filesystem::is_regular_file(path)) throw FileNotFoundException(path);}
开发者ID:Helios-vmg,项目名称:zekvok,代码行数:7,
示例10: FileReader::FileReader(const String& fileName) { this->file = newInstance<std::ifstream>(StringUtils::toUTF8(fileName).c_str(), std::ios::binary | std::ios::in); if (!file->is_open()) boost::throw_exception(FileNotFoundException(fileName)); _length = FileUtils::fileLength(fileName); }
开发者ID:alesha1488,项目名称:LucenePlusPlus,代码行数:7,
示例11: invoid ConfigFile::load( const std::string fileName, const std::string delimiter, const std::string comment, const std::string inc, const std::string sentry ){ // Construct a ConfigFile, getting keys and values from given file // the old values std::string delimiter1 = _delimiter; std::string comment1 = _comment; std::string inc1 = _include; std::string sentry1 = _sentry; if (delimiter != "") _delimiter = delimiter; if (comment != "") _comment = comment; if (inc != "") _include = inc; if (sentry != "") _sentry = sentry; std::ifstream in( fileName.c_str() ); if( !in ) { throw FileNotFoundException(fileName); } in >> (*this); _delimiter = delimiter1; _comment = comment1; _include = inc1; _sentry = sentry1;}
开发者ID:esheldon,项目名称:misc,代码行数:30,
示例12: switchvoid FileImpl::handleLastErrorImpl(const std::string& path){ switch (errno) { case EIO: throw IOException(path); case EPERM: throw FileAccessDeniedException("insufficient permissions", path); case EACCES: throw FileAccessDeniedException(path); case ENOENT: throw FileNotFoundException(path); case ENOTDIR: throw OpenFileException("not a directory", path); case EISDIR: throw OpenFileException("not a file", path); case EROFS: throw FileReadOnlyException(path); case EEXIST: throw FileExistsException(path); case ENOSPC: throw FileException("no space left on device", path); case ENOTEMPTY: throw FileException("directory not empty", path); case ENAMETOOLONG: throw PathSyntaxException(path); case ENFILE: case EMFILE: throw FileException("too many open files", path); default: throw FileException(std::strerror(errno), path); }}
开发者ID:as2120,项目名称:ZPoco,代码行数:33,
示例13: CreateWatch//--------WatchID FileWatcherWin32::addWatch(const String& directory, FileWatchListener* watcher, bool recursive){ WatchID watchid = ++mLastWatchID; WatchStruct* watch = CreateWatch( directory.c_str(), FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_FILE_NAME, recursive); if(!watch) { std::ostringstream message; message << "In " << __FILE__ << " at line " << __LINE__ << ": "; throw FileNotFoundException(directory, message.str()); } watch->mWatchid = watchid; watch->mFileWatcher = this; watch->mFileWatchListener = watcher; watch->mRecursive = recursive; watch->mDirName = new char[directory.length()+1]; strcpy(watch->mDirName, directory.c_str()); mWatches.insert(std::make_pair(watchid, watch)); return watchid;}
开发者ID:151706061,项目名称:Slicer3,代码行数:29,
示例14: fin Entity* EntityCreator::CreateFromFile(const string& filepath) { std::ifstream fin(filepath, std::ios::in); if (fin) { Json::Value rootNode; Json::Reader reader; bool success = reader.parse(fin, rootNode); if (success) { Model* model = nullptr; PhysicsBody* body = nullptr; if (CheckExistence(rootNode, "model")) { const Json::Value& modelNode = rootNode["model"]; model = ModelCreator::CreateFromJson(modelNode); } if (CheckExistence(rootNode, "body")) { const Json::Value& bodyNode = rootNode["body"]; body = PhysicsCreator::CreateFromJson(bodyNode, model); } Entity* entity = new Entity(model, body); return entity; } else { throw Exception("SceneCreator: Cannot parse file '" + filepath + "': " + reader.getFormatedErrorMessages()); } } else { throw FileNotFoundException(filepath); } }
开发者ID:panmar,项目名称:pg2,代码行数:30,
示例15: addAll void addAll() { // add base dir int fd = open(mDirName.c_str(), O_RDONLY | O_EVTONLY); EV_SET(&mChangeList[0], fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT, NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB, 0, 0); //fprintf(stderr, "ADDED: %s/n", mDirName.c_str()); // scan directory and call addFile(name, false) on each file DIR* dir = opendir(mDirName.c_str()); if(!dir) throw FileNotFoundException(mDirName); struct dirent* entry; struct stat attrib; while((entry = readdir(dir)) != NULL) { String fname = (mDirName + "/" + String(entry->d_name)); stat(fname.c_str(), &attrib); if(S_ISREG(attrib.st_mode)) addFile(fname, false); //else // fprintf(stderr, "NOT ADDED: %s (%d)/n", fname.c_str(), attrib.st_mode); }//end while closedir(dir); }
开发者ID:Harteex,项目名称:ExLauncher,代码行数:31,
示例16: addFile void addFile(const String& name, bool imitEvents = true) { //fprintf(stderr, "ADDED: %s/n", name.c_str()); // create entry struct stat attrib; stat(name.c_str(), &attrib); int fd = open(name.c_str(), O_RDONLY | O_EVTONLY); if(fd == -1) throw FileNotFoundException(name); ++mChangeListCount; char* namecopy = new char[name.length() + 1]; strncpy(namecopy, name.c_str(), name.length()); namecopy[name.length()] = 0; EntryStruct* entry = new EntryStruct(namecopy, mWatchID, attrib.st_mtime); // set the event data at the end of the list EV_SET(&mChangeList[mChangeListCount], fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT/* | EV_CLEAR*/, NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB | NOTE_RENAME | NOTE_LINK | NOTE_REVOKE, 0, (void*)entry); // qsort qsort(mChangeList + 1, mChangeListCount, sizeof(KEvent), comparator); // handle action if(imitEvents) handleAction(name, Actions::Add); }
开发者ID:Harteex,项目名称:ExLauncher,代码行数:33,
示例17: throwstd::vector<Task>* Parser::parse_stg(const char *filepath, DirectedAcyclicGraph* &graph) throw(FileNotFoundException) { enum section { HEADER, GRAPH, FOOTER }; std::vector<Task>* tasks = NULL; section s = HEADER; std::ifstream file(filepath); if(!file) throw FileNotFoundException(filepath); unsigned int task_count = 0; while(file.good()) { if(s == HEADER) { file >> task_count; if (task_count !=0) { // STG format always includes two dummy nodes task_count = task_count + 2; graph = new DirectedAcyclicGraph(task_count); tasks = new std::vector<Task>(task_count); s = GRAPH; } } else if(s == GRAPH) {
开发者ID:VT-Magnum-Research,项目名称:dove,代码行数:28,
示例18: removeFile void removeFile(const String& name, bool imitEvents = true) { // bsearch KEvent target; EntryStruct tempEntry(name.c_str(), 0); target.udata = &tempEntry; KEvent* ke = (KEvent*)bsearch(&target, &mChangeList, mChangeListCount + 1, sizeof(KEvent), comparator); if(!ke) throw FileNotFoundException(name); tempEntry.mFilename = 0; // delete close(ke->ident); delete((EntryStruct*)ke->udata); memset(ke, 0, sizeof(KEvent)); // move end to current memcpy(ke, &mChangeList[mChangeListCount], sizeof(KEvent)); memset(&mChangeList[mChangeListCount], 0, sizeof(KEvent)); --mChangeListCount; // qsort qsort(mChangeList + 1, mChangeListCount, sizeof(KEvent), comparator); // handle action if(imitEvents) handleAction(name, Actions::Delete); }
开发者ID:Harteex,项目名称:ExLauncher,代码行数:29,
示例19: CreateFileWutils::File::File(const zchar* const filename, FileAccess access, FileShare share, FileMode mode, FileType type){ hFile = CreateFileW(filename, static_cast<DWORD>(access), static_cast<DWORD>(share), nullptr, static_cast<DWORD>(mode), static_cast<DWORD>(type), nullptr); if (hFile == INVALID_HANDLE_VALUE) { OutputDebugStringW(L"Something is wrong:/n"); auto error = GetLastError(); switch (error) { case ERROR_FILE_EXISTS: OutputDebugStringW(L"File already exists./n"); throw FileAlreadyExistsException(); case ERROR_FILE_NOT_FOUND: OutputDebugStringW(L"File not found./n"); throw FileNotFoundException(); case ERROR_SHARING_VIOLATION: OutputDebugStringW(L"File cannot be shared./n"); throw FileSharingViolationException(); default: OutputDebugStringW(L"Reason is not defined./n"); throw FileException(); } }}
开发者ID:kazami-yuuji,项目名称:ZariDB,代码行数:26,
示例20: computeSHA1/** * Compute the SHA1 hash for the given file. * @param filename The filename (with or without prefixed by a path). If the file * is not found the exeption 'FileNotFoundException' is thrown. * @param bufferSize The size of the buffer used to give the data to 'QCryptographicHash'. * @return The sha1 hash. */QByteArray computeSHA1(const QString& filename, qint32 bufferSize) throw (FileNotFoundException){#if not WITH_SHA1_LINUS QCryptographicHash crypto(QCryptographicHash::Sha1);#endif QFile file(filename); if (!file.open(QIODevice::ReadOnly)) throw FileNotFoundException();#if WITH_SHA1_LINUS blk_SHA_CTX sha1State; blk_SHA1_Init(&sha1State); unsigned char bufferHash[20];#endif char buffer[bufferSize]; qint64 bytesRead = 0; while ((bytesRead = file.read(buffer, bufferSize)) > 0) {#if WITH_SHA1_LINUS blk_SHA1_Update(&sha1State, buffer, bytesRead);#else crypto.addData(buffer, bytesRead);#endif }#if WITH_SHA1_LINUS blk_SHA1_Final(bufferHash, &sha1State); return QByteArray((const char*)bufferHash, 20);#else return crypto.result();#endif}
开发者ID:Fafou,项目名称:D-LAN,代码行数:42,
示例21: Exceptionvoid ImageImporter::execute() { if (mFilename == "") throw Exception("No filename was supplied to the ImageImporter"); uchar* convertedPixelData; // Load image from disk using Qt QImage image; reportInfo() << "Trying to load image..." << Reporter::end(); if(!image.load(mFilename.c_str())) { throw FileNotFoundException(mFilename); } reportInfo() << "Loaded image with size " << image.width() << " " << image.height() << Reporter::end(); QImage::Format format; if(mGrayscale) { format = QImage::Format_Grayscale8; } else { format = QImage::Format_RGB888; } QImage convertedImage = image.convertToFormat(format); // Get pixel data convertedPixelData = convertedImage.bits(); Image::pointer output = getOutputData<Image>(); std::cout << "image info" << std::endl; std::cout << convertedImage.width() << std::endl; std::cout << convertedImage.depth() << std::endl; std::cout << convertedImage.bytesPerLine() << std::endl; if(convertedImage.width()*convertedImage.depth()/8 != convertedImage.bytesPerLine()) { const int bytesPerPixel = (convertedImage.depth()/8); std::unique_ptr<uchar[]> fixedPixelData = std::make_unique<uchar[]>(image.width()*image.height()); // Misalignment for(int scanline = 0; scanline < image.height(); ++scanline) { std::memcpy( &fixedPixelData[scanline*image.width()*bytesPerPixel], &convertedPixelData[scanline*convertedImage.bytesPerLine()], image.width()*bytesPerPixel ); } output->create( image.width(), image.height(), TYPE_UINT8, mGrayscale ? 1 : 3, getMainDevice(), fixedPixelData.get() ); } else { output->create( image.width(), image.height(), TYPE_UINT8, mGrayscale ? 1 : 3, getMainDevice(), convertedPixelData ); }}
开发者ID:smistad,项目名称:FAST,代码行数:59,
示例22: throwbool File::open() throw(FileNotFoundException){ if(!exists()) throw FileNotFoundException(path); inStream = new std::ifstream(path, std::ifstream::binary); return this->isOpen();}
开发者ID:OpenMarshal,项目名称:DnsServer,代码行数:8,
示例23: FileNotFoundExceptionFont* Font::CreateFont(std::string file) { if(exists(file.c_str()) == false) { throw FileNotFoundException(file); } if(std::string(get_extension(file.c_str())).compare("bmp") != 0) { throw TypeNotSupportedException("Non-.bmp"); } return (new Font(file));}
开发者ID:cugone,项目名称:Abrams2010,代码行数:9,
示例24: assert CFile::CFile(const char* fname, const char* mode) { assert(fname != NULL && mode != NULL); m_fp = fopen(fname, mode); if(m_fp == NULL) { throw FileNotFoundException(EXCEPTION_TRACE, "fopen error"); } }
开发者ID:KarserZero,项目名称:tuxone,代码行数:9,
示例25: ReadNextDatastring FileReader::ReadNextData() { if (fileHandle == NULL) throw FileNotFoundException(); // if we have no more data, return empty string if (fgets(buffer, bufferSize, fileHandle) == NULL) return string(); return string(buffer);}
开发者ID:quom,项目名称:oculus-trading-desk,代码行数:9,
示例26: addFile void Package::addFile(const std::string& input, const std::string& target) { // At the moment, Package just supports adding files to the package. // It does not allow you to modify an existing file. So, if the user // is trying to add an existing file, we return: if (fileIndex.count(target) > 0 || !file.is_open()) { return; } std::ifstream newFile; // The file is open in binary read mode. The pointer is located at the // end of the file. newFile.open(input, std::ios_base::in | std::ios_base::binary | std::ios_base::ate); if (!newFile.is_open()) throw FileNotFoundException(input); // Since the pointer is at the end, tellg() tells us the size of the file. unsigned long size = newFile.tellg(); // We move the pointer at the beginning. newFile.seekg(0); // In the output file, we move the cursor at the end of the file. // We will write the new file there. file.seekg(0, std::ios_base::end); // Write the size of the file. file.write((const char *)&size, SIZE_BYTES); // The filename is going to be stored temporarily in an array. char name[NAME_BYTES]; // We clean the memory. std::memset(name, 0, NAME_BYTES); // Then we copy the name. std::memcpy(name, target.c_str(), target.size()); // And we write it on the file. file.write(name, NAME_BYTES); // Note: writing just file.write(target.c_str(), NAME_BYTES) can give // problems if target.size() < NAME_SIZE because the memory could be dirty. // The pointer is still pointing at the beginning of the file. It's the // right moment to add the new file to the index: fileIndex[std::string(target)] = PackageFileInfo(file.tellp(), size); char byte; // Finally, we copy the contents of the file in the package. while (!newFile.eof()) { newFile.read(&byte, 1); if (newFile.eof()) break; file.write((const char *)&byte, 1); } newFile.close(); file.clear(); }
开发者ID:RafaelGC,项目名称:ESE,代码行数:56,
示例27: create void Package::create(const std::string& fileName, unsigned int compression) { packageName = fileName; file.open(fileName, std::ios_base::in | std::ios_base::out | std::ios_base::binary | std::ios_base::trunc); if (!file.is_open()) throw FileNotFoundException(fileName); file.write(MAGIC_NUMBER, 4); file.write((char *)&VERSION, 4); file.write((char *)&compression, 4); }
开发者ID:RafaelGC,项目名称:ESE,代码行数:10,
示例28: open void Package::open(const std::string& fileName) { packageName = fileName; // Open the file en binary read/write mode. file.open(fileName, std::ios_base::in | std::ios_base::out | std::ios_base::binary | std::ios_base::app); if (!file.is_open()) throw FileNotFoundException(fileName); // Instead of loading all files in memory when this method is called, // it just builds an index to be able to load files faster when the user // requests them. // The index relates the filename with its position and size. unsigned long position = 12; // 4 (MAGIC) + 4 (VERSION) + 4 (COMPRESSION) file.seekg(position); // For each file... while (!file.eof()) { unsigned long size; // 1. Get the file size. Note: the size does NOT include the size of the // filename. file.read((char *)&size, SIZE_BYTES); if (file.eof()) break; char name[NAME_BYTES]; // 2. Read the name/path of the file. file.read(name, NAME_BYTES); if (file.eof()) break; // El cursor ahora mismo está en <<position>>, apuntando al inicio // del archivo empaquetado. // 3. Store the position and size of the file. // Note that <<position>> is NOT really pointing to the file but // to the file size. After the file size is the file name. That's // why we must calculate position + SIZE_BYTES + NAME_BYTES to // get the actual file position in our package. fileIndex[std::string(name)] = PackageFileInfo(position + NAME_BYTES + SIZE_BYTES, size); // We move the pointer to the next file header. position += size + SIZE_BYTES + NAME_BYTES; file.seekg(position); } // After reading the file fome error flags can be activated. // If we want to use <<file>> later (for example, with addFile()) those // error flags will give problems. // Calling file.clear() we avoid that. file.clear(); }
开发者ID:RafaelGC,项目名称:ESE,代码行数:55,
示例29: input /** * * This function will throw an IllegalArgumentException if the file contents cannot be multibyte decoded. */ void PropertiesConfiguration::load(const String &file) { // std::clog << "Loading properties file: " << file << std::endl; std::ifstream input(file.c_str(), std::ifstream::in); // fail() catches File Not Found, bad() does not. ASSERT(!input.fail()); if (input.fail()) throw FileNotFoundException("Failed to open file for read: " + file); parseStream(input); }
开发者ID:dreadlock,项目名称:owasp-esapi-cplusplus,代码行数:15,
示例30: FileNotFoundExceptionvoid InMemoryStorageBackend::openFileStream(std::ifstream &stream, const std::string &filename, bool isBackupValid) { // TODO: Consider adding exceptions to streams and handling them: // stream.exceptions(std::ifstream::failbit | std::ifstream::badbit); stream.open(filename); if (!stream.is_open()) { throw FileNotFoundException(filename); } m_checksum.compare(stream, filename, isBackupValid);}
开发者ID:pohly,项目名称:cynara,代码行数:12,
注:本文中的FileNotFoundException函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ FileOpen函数代码示例 C++ FileInfo函数代码示例 |