当前位置: 首页>>代码示例>>C++>>正文


C++ FileNotFoundException函数代码示例

本文整理汇总了C++中FileNotFoundException函数的典型用法代码示例。如果您正苦于以下问题:C++ FileNotFoundException函数的具体用法?C++ FileNotFoundException怎么用?C++ FileNotFoundException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FileNotFoundException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MergeStreams

void 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,代码来源:ExceptionDemo2.cpp

示例2: FileNotFoundException

int 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,代码来源:JpegStegoDecoder.cpp

示例3: poco_assert

void 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,代码来源:File_VMS.cpp

示例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,代码来源:Path.cpp

示例5: StripShaderName

std::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,代码来源:ShaderManager.cpp

示例6: templatePath

Path 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,代码来源:TemplateCache.cpp

示例7: is

void 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,代码来源:CFileContent.cpp

示例8: GetLastError

void 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,代码来源:SerialChannel_WIN32U.cpp

示例9: manifest_offset

ArchiveReader::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,代码来源:ArchiveIO.cpp

示例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,代码来源:FileReader.cpp

示例11: in

void 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,代码来源:ConfigFile.cpp

示例12: switch

void 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,代码来源:File_VX.cpp

示例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,代码来源:FileWatcherWin32.cpp

示例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,代码来源:EntityCreator.cpp

示例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,代码来源:FileWatcherOSX.cpp


注:本文中的FileNotFoundException函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。