Stream *VFSFile::create( const URI& uri, const CParams &p, bool &bSuccess ) { int omode = paramsToMode( p ); if ( p.isNoOvr() ) omode |= O_EXCL; //TODO: something about sharing AutoCString cfilename( uri.path() ); errno=0; umask( 0000 ); int handle = ::open( cfilename.c_str(), O_CREAT | omode, p.createMode() ); if ( handle >= 0 ) { bSuccess = true; if ( ! p.isNoStream() ) { UnixFileSysData *ufd = new UnixFileSysData( handle, 0 ); return new StreamBuffer( new FileStream( ufd ) ); } else return 0; } bSuccess = false; return 0; }
void FileTrasferTask::Start(std::string filename) { std::cout<<"创建输出文件"<<filename<<std::endl; CString cfilename(filename.c_str()); HRESULT hr=m_file.Create(cfilename,GENERIC_WRITE, 0, CREATE_ALWAYS); if(FAILED(hr)){ std::cout<<"打开文件错误"<<std::endl; } }
StorageObject * PosixStorageManager::makeStorageObject(const StringC &spec, const StringC &base, Boolean search, Boolean mayRewind, Messenger &mgr, StringC &found) { if (spec.size() == 0) { mgr.message(PosixStorageMessages::invalidFilename, StringMessageArg(spec)); return 0; } descriptorManager_.acquireD(); Boolean absolute = isAbsolute(spec); SearchResultMessageArg sr; for (size_t i = 0; i < searchDirs_.size() + 1; i++) { StringC filename; if (absolute) filename = spec; else if (i == 0) filename = combineDir(extractDir(base), spec); else filename = combineDir(searchDirs_[i - 1], spec); #ifdef SP_WIDE_SYSTEM String<FChar> cfilename(filename); cfilename += FChar(0); #else String<FChar> cfilename = filenameCodingSystem_->convertOut(filename); #endif int fd; do { fd = openFile(cfilename.data()); } while (fd < 0 && errno == EINTR); if (fd >= 0) { found = filename; return new PosixStorageObject(fd, filename, cfilename, mayRewind, &descriptorManager_); } int savedErrno = errno; if (absolute || !search || searchDirs_.size() == 0) { ParentLocationMessenger(mgr).message(PosixStorageMessages::openSystemCall, StringMessageArg(filename), ErrnoMessageArg(savedErrno)); descriptorManager_.releaseD(); return 0; } sr.add(filename, savedErrno); } descriptorManager_.releaseD(); ParentLocationMessenger(mgr).message(PosixStorageMessages::cannotFind, StringMessageArg(spec), sr); return 0; }
CString fileSystemRepresentation(const String& path) { // WARNING: this is just used by platform/network/soup, thus must be GLIB!!! // TODO: move this to CString and use it instead in both, being more standard #if !PLATFORM(WIN_OS) && defined(USE_SOUP) char* filename = g_uri_unescape_string(path.utf8().data(), 0); CString cfilename(filename); g_free(filename); return cfilename; #else return path.utf8(); #endif }
Stream *VFSFile::open( const URI& uri, const OParams &p ) { int omode = paramsToMode( p ); // todo: do something about share mode AutoCString cfilename( uri.path() ); errno = 0; int handle = ::open( cfilename.c_str(), omode ); if ( handle >= 0 ) { UnixFileSysData *ufd = new UnixFileSysData( handle, 0 ); return new StreamBuffer( new FileStream( ufd ) ); } return 0; }