void OperCFThread::CreateDirectory( FS* fs, FSPath& srcPath, FSPath& destPath, bool processMultipleFolders ) { if ( processMultipleFolders ) { const int DirIndex = srcPath.GetFirstUnmatchedItem( destPath ); FSPath Path; for ( int i = 0; i < destPath.Count(); i++ ) { // get next dir Path.PushStr( *destPath.GetItem( i ) ); int ret_err; // try to create dir if ( i >= DirIndex && fs->MkDir( Path, 0777, &ret_err, Info() ) ) { // skip "already exists" error if ( !fs->IsEEXIST( ret_err ) ) { throw_msg( "%s", fs->StrError( ret_err ).GetUtf8() ); } } } } else { int ret_err; if ( fs->MkDir( destPath, 0777, &ret_err, Info() ) ) { throw_msg( "%s", fs->StrError( ret_err ).GetUtf8() ); } } }
int LoadToTempFile( NCDialogParent* parent, clPtr<FS>* fs, FSPath* path ) { clPtr<FS> TempFs; FSPath TempPath; const int TempId = CreateWcmTempDir( &TempFs, &TempPath ); if ( !TempId ) { return 0; } // append file name to the created temp dir FSPath DstPath = TempPath; DstPath.Push( CS_UTF8, path->GetItem( path->Count() - 1 )->GetUtf8() ); LoadFileDataThreadDlg dlg( parent, *fs, *path, TempFs, DstPath ); dlg.RunNewThread( "Load file", LoadFileDataThreadFunc, &dlg.m_Data ); dlg.DoModal(); if ( !dlg.m_Data.m_Success ) { // cleanup created temp dir RemoveWcmTempDir( TempId ); return 0; } *fs = TempFs; *path = DstPath; return TempId; }
bool OperCFThread::DeleteList( FS* fs, FSPath& _path, FSList& list ) { if ( Info()->Stopped() ) { return false; } FSPath path = _path; int cnt = path.Count(); for ( FSNode* node = list.First(); node; node = node->next ) { if ( node->extType ) { continue; } path.SetItemStr( cnt, node->Name() ); if ( node->IsDir() && !node->st.IsLnk() ) { if ( !DeleteDir( fs, path ) ) { return false; } if ( !RmDir( fs, path ) ) { return false; } continue; } if ( !DeleteFile( fs, path ) ) { return false; } } return true; }
void SaveStringList(const char *section, ccollect< carray<char> > &list) { try { SysTextFileOut out; FSPath path = configDirPath; path.Push(CS_UTF8, carray_cat<char>(section, ".cfg").ptr()); out.Open( (sys_char_t*)path.GetString(sys_charset_id) ); for (int i = 0; i<list.count(); i++) { if (list[i].ptr() && list[i][0]) { out.Put(list[i].ptr()); out.PutC('\n'); } } out.Flush(); out.Close(); } catch (cexception *ex) { ex->destroy(); return ; } }
bool DeleteListRecursively( FS* fs, FSPath path, FSList& list ) { const int cnt = path.Count(); int ret_err; for ( FSNode* node = list.First(); node; node = node->next ) { if ( node->extType ) { continue; } path.SetItemStr( cnt, node->Name() ); if ( node->IsDir() && !node->st.IsLnk() ) { if ( !DeleteDirRecursively( fs, path ) ) { return false; } } else if ( fs->Delete( path, &ret_err, nullptr ) != 0 ) { return false; } } return true; }
int FSTmp::Delete(FSPath& path, int* err, FSCInfo* info) { FSString* dName = path.GetItem(path.Count() - 1); FSTmpNode* n = rootDir.findByName(dName); if (n == 0) { return FS::SetError(err, FSTMP_ERROR_FILE_NOT_FOUND);; } else { /* if (n->nodeType == FSTmpNode::NODE_FILE) { // remove file at base FS int ret = baseFS->Delete(n->baseFSPath, err, info); if (ret != 0) return ret; } */ // remove from tmpfs list for (auto it = n->parentDir->content.begin(); it != n->parentDir->content.end(); ++it) { if ((*it).name.Cmp(*dName) == 0) { n->parentDir->content.erase(it); return FS::SetError(err, 0); } } return FS::SetError(err, FSTMP_ERROR_FILE_NOT_FOUND);; } }
int FSSys::Stat( FSPath& path, FSStat* fsStat, int* err, FSCInfo* info ) { fsStat->link.Clear(); #ifdef S_IFLNK struct stat st_link; if ( lstat( ( char* )path.GetString( sys_charset_id ), &st_link ) ) { SetError( err, errno ); return -1; }; if ( ( st_link.st_mode & S_IFMT ) == S_IFLNK ) { char buf[1024]; ssize_t ret = readlink( ( char* )path.GetString( sys_charset_id ), buf, sizeof( buf ) ); if ( ret >= sizeof( buf ) ) { ret = sizeof( buf ) - 1; } if ( ret >= 0 ) { buf[ret] = 0; } else { buf[0] = 0; } if ( ret >= 0 ) { fsStat->link.Set( sys_charset_id, buf ); } } else { fsStat->mode = st_link.st_mode; fsStat->size = st_link.st_size; fsStat->mtime = st_link.st_mtime; fsStat->gid = st_link.st_gid; fsStat->uid = st_link.st_uid; fsStat->dev = st_link.st_dev; fsStat->ino = st_link.st_ino; return 0; } #endif struct stat st; if ( stat( ( char* )path.GetString( sys_charset_id ), &st ) ) { SetError( err, errno ); return -1; } fsStat->mode = st.st_mode; fsStat->size = st.st_size; fsStat->mtime = st.st_mtime; fsStat->gid = st.st_gid; fsStat->uid = st.st_uid; fsStat->dev = st.st_dev; fsStat->ino = st.st_ino; return 0; }
clPtr<FS> clArchPlugin::OpenFS( clPtr<FS> Fs, FSPath& Path ) const { FSString Uri = Fs->Uri( Path ); struct archive* Arch = ArchOpen( Uri.GetUtf8() ); if ( Arch == nullptr ) { return nullptr; } FSArchNode RootDir; RootDir.fsStat.mode = S_IFDIR; FSPath NodePath; struct archive_entry* entry = archive_entry_new2( Arch ); int Res; while ( ( Res = archive_read_next_header2( Arch, entry ) ) == ARCHIVE_OK ) { NodePath.Set( CS_UTF8, archive_entry_pathname( entry ) ); FSString* ItemName = NodePath.GetItem( NodePath.Count() - 1 ); if ( NodePath.Count() == 1 && ( ItemName->IsDot() || ItemName->IsEmpty() ) ) { // skip root dir continue; } const mode_t Mode = archive_entry_mode( entry ); const int64_t Size = archive_entry_size( entry ); RootDir.entryOffset += Size; FSStat ItemStat; ItemStat.mode = S_ISREG( Mode ) ? Mode : S_IFDIR; ItemStat.size = Size; ItemStat.m_CreationTime = archive_entry_ctime( entry ); ItemStat.m_LastAccessTime = archive_entry_atime( entry ); ItemStat.m_LastWriteTime = archive_entry_mtime( entry ); ItemStat.m_ChangeTime = ItemStat.m_LastWriteTime; FSArchNode* Dir = ArchGetParentDir( &RootDir, NodePath, ItemStat ); FSArchNode* Item = Dir->Add( FSArchNode( ItemName->GetUtf8(), ItemStat ) ); if (Item) { Item->entryOffset = archive_read_header_position( Arch ); } } if ( Res != ARCHIVE_EOF ) { dbg_printf( "Couldn't read archive entry: %s\n", archive_error_string( Arch ) ); } archive_entry_free( entry ); ArchClose( Arch ); return new FSArch( RootDir, Uri ); }
void FileSystem::chmkdir(FSPath &path) { goRoot(); for (FSPath::iterator it = path.begin(); it != path.end(); it++) chmkdir(it->c_str()); }
void testFS() { FileSystem fs; fs.root().dump(cout); cout << "\n"; FSPath pwd = fs.pwdir(); pwd.dump(cout); cout << "\n"; }
int FSSys::Rename ( FSPath& oldpath, FSPath& newpath, int* err, FSCInfo* info ) { if ( MoveFileW( SysPathStr( _drive, oldpath.GetUnicode( '\\' ) ).data(), SysPathStr( _drive, newpath.GetUnicode( '\\' ) ).data() ) ) { return 0; } SetError( err, GetLastError() ); return -1; }
int FSSys::Rename ( FSPath& oldpath, FSPath& newpath, int* err, FSCInfo* info ) { if ( rename( ( char* ) oldpath.GetString( sys_charset_id, '/' ), ( char* ) newpath.GetString( sys_charset_id, '/' ) ) ) { SetError( err, errno ); return -1; } return 0; }
int FSSftp::OpenCreate ( FSPath& path, bool overwrite, int mode, int* err, FSCInfo* info ) { MutexLock lock( &mutex ); int ret = CheckSession( err, info ); if ( ret ) { return ret; } if ( !overwrite ) { /* заебался выяснять почему sftp_open с O_EXCL выдает "generc error" при наличии файла, а не EEXIST какой нибудь поэтому встанил эту дурацкую проверку на наличие */ sftp_attributes a = sftp_lstat( sftpSession, ( char* ) path.GetString( _operParam.charset, '/' ) ); if ( a ) { sftp_attributes_free( a ); //!!! if ( err ) { *err = SSH_FX_FILE_ALREADY_EXISTS; } return -1; } } int n = 0; for ( ; n < MAX_FILES; n++ ) if ( !fileTable[n] ) { break; } if ( n >= MAX_FILES ) { if ( err ) { *err = SSH_INTERROR_OUTOF; } return -1; } sftp_file f = sftp_open( sftpSession, ( char* ) path.GetString( _operParam.charset, '/' ), O_CREAT | O_WRONLY | ( overwrite ? O_TRUNC : O_EXCL ), mode ); if ( !f ) { //printf("ssh-err:'%s'\n",ssh_get_error(sshSession)); if ( err ) { *err = sftp_get_error( sftpSession ); } return -1; } fileTable[n] = f; return n; }
int FSTmp::MkDir(FSPath& path, int mode, int* err, FSCInfo* info) { FSPath parentPath; parentPath.Copy(path, path.Count() - 1); FSTmpNode* parent = rootDir.findByFsPath(&parentPath); if (!parent) return SetError(err, FSTMP_ERROR_FILE_NOT_FOUND); FSTmpNode* parentDir = parent; FSTmpNode fsTmpNode(path.GetItem(path.Count() - 1)->GetUnicode(), parentDir); parentDir->Add(&fsTmpNode); return SetError(err, 0); }
static void stripPathFromLastItem(FSPath& path) { FSString* lastItem = path.GetItem(path.Count() - 1); if (lastItem) { const unicode_t* lastU = lastItem->GetUnicode(); const unicode_t* lastDelim = unicode_strrchr(lastU, DIR_SPLITTER); if (lastDelim != 0) { path.SetItemStr(path.Count() - 1,FSString(lastDelim + 1)); } } }
int FSSys::Stat( FSPath& path, FSStat* fsStat, int* err, FSCInfo* info ) { if ( _drive >= 0 && path.Count() == 1 || _drive == -1 && path.Count() == 3 ) { //pseudo stat fsStat->size = 0; fsStat->dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; fsStat->mode = S_IFDIR; fsStat->mtime = 0; fsStat->mode |= 0664; return 0; } WIN32_FIND_DATAW ent; HANDLE handle = FindFirstFileW( SysPathStr( _drive, path.GetUnicode() ).data(), &ent ); if ( handle == INVALID_HANDLE_VALUE ) { SetError( err, GetLastError() ); return -1; } try { fsStat->size = ( seek_t( ent.nFileSizeHigh ) << 32 ) + ent.nFileSizeLow; fsStat->dwFileAttributes = ent.dwFileAttributes; fsStat->mtime = ent.ftLastWriteTime; if ( ent.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { fsStat->mode = S_IFDIR; } else { fsStat->mode = S_IFREG; } fsStat->mode |= 0664; FindClose( handle ); return 0; } catch ( ... ) { FindClose( handle ); throw; } //... SetError( err, 50 ); return -1; }
FSPath FileSystem::pwdir() { FSPath pwd; char path[255] = {0}; getcwd(path, sizeof(path)); for (char *token = strtok(path, "/"); token != NULL; ) { pwd.push_back(token); token = strtok(NULL, "/"); } return pwd; }
bool OperCFThread::Copy(FS *srcFs, FSPath &__srcPath, FSList *list, FS *destFs, FSPath &__destPath, cstrhash<bool,unicode_t> &resList) { if (list->Count()<=0) return true; FSPath srcPath = __srcPath; int srcPos = srcPath.Count(); FSPath destPath = __destPath; int destPos = destPath.Count(); FSStat st; int ret_error; int res = destFs->Stat(__destPath, &st, &ret_error, Info()); if (res == -2) return false; if (res && !destFs->IsENOENT(ret_error)) { RedMessage( _LT("Can't copy to:\n"), destFs->Uri(destPath).GetUtf8(), bOk, destFs->StrError(ret_error).GetUtf8()); return false; } bool exist = (res == 0); if (list->Count()>1) { //если файлов >1 то копировать можно только в каталог if (!exist) { RedMessage( _LT("Can't copy files, destination is not found:\n"), destFs->Uri(__destPath).GetUtf8(), bOk); return false; } if (!st.IsDir()) { RedMessage( _LT("Destination is not directory:\n"), destFs->Uri(__destPath).GetUtf8(), bOk); return false; } for (FSNode *node = list->First(); node; node = node->next) { if (Info()->Stopped()) return false; srcPath.SetItemStr(srcPos, node->Name()); destPath.SetItemStr(destPos, node->Name()); if (!CopyNode(srcFs, srcPath, node, destFs, destPath, false)) return false; resList[node->Name().GetUnicode()] = true; } } else { // 1 element if (exist && st.IsDir()) destPath.SetItemStr(destPos, list->First()->Name()); srcPath.SetItemStr(srcPos, list->First()->Name()); if (!CopyNode(srcFs, srcPath, list->First(), destFs, destPath, false)) return false; resList[list->First()->Name().GetUnicode()] = true; }; return true; }
int FSTmp::RmDir(FSPath& path, int* err, FSCInfo* info) { FSTmpNode* n = rootDir.findByFsPath(&path); FSString* dirName = path.GetItem(path.Count() - 1); for (auto it = n->parentDir->content.begin(); it != n->parentDir->content.end(); ++it) { if ((*it).name.Cmp(*dirName) == 0) { n->parentDir->content.erase(it); return FS::SetError(err, 0); } } return FS::SetError(err, FSTMP_ERROR_FILE_NOT_FOUND); }
void FSPath::Copy(const FSPath& a, int elementCount) { cacheCs = -2; data.clear(); if (elementCount<0 || elementCount>a.Count()) elementCount = a.Count(); for (int i = 0; i < elementCount; i++) { FSString s; s.Copy(a.data.const_item(i)); data.append(s); } }
bool OperCFThread::Move(FS *srcFs, FSPath &__srcPath, FSList *list, FS *destFs, FSPath &__destPath) { if (list->Count()<=0) return true; FSPath srcPath = __srcPath; int srcPos = srcPath.Count(); FSPath destPath = __destPath; int destPos = destPath.Count(); FSStat st; int ret_error; int r = destFs->Stat(__destPath, &st, &ret_error, Info()); if (r == -2) return false; if (list->Count()>1) { //если файлов >1 то копировать можно только в каталог if (r) { RedMessage( _LT("Can't move files, bad destination directory:\n"), destFs->Uri(__destPath).GetUtf8(), bOk, destFs->StrError(ret_error).GetUtf8()); return false; } if (!st.IsDir()) { RedMessage( _LT("Destination is not directory:\n"), destFs->Uri(__destPath).GetUtf8(), bOk); return false; } for (FSNode *node = list->First(); node; node = node->next) { srcPath.SetItemStr(srcPos, node->Name()); destPath.SetItemStr(destPos, node->Name()); //printf("MOVE '%s'\n", srcPath.GetUtf8()); if (!MoveNode(srcFs, srcPath, node, destFs, destPath)) return false; } } else { // 1 element if (r && !destFs->IsENOENT(ret_error)) { RedMessage( _LT("Can't move to:\n"), destFs->Uri(destPath).GetUtf8(), bOk, destFs->StrError(ret_error).GetUtf8()); return false; } if (!r && st.IsDir()) destPath.SetItemStr(destPos, list->First()->Name()); FSNode *node = list->First(); srcPath.SetItemStr(srcPos, list->First()->Name()); if (!MoveNode(srcFs, srcPath, list->First(), destFs, destPath)) return false; } return true; }
void WcmConfig::Save( NCWin* nc ) { if ( nc ) { leftPanelPath = new_char_str( nc->GetLeftPanel()->GetPath().GetUtf8() ); rightPanelPath = new_char_str( nc->GetRightPanel()->GetPath().GetUtf8() ); crect Rect = nc->ScreenRect(); windowX = Rect.top; windowY = Rect.left; windowWidth = Rect.Width(); windowHeight = Rect.Height(); } #ifdef _WIN32 for (int i = 0; i<mapList.count(); i++) { Node &node = mapList[i]; if (node.type == MT_BOOL && node.ptr.pBool != 0) RegWriteInt(node.section, node.name, *node.ptr.pBool); else if (node.type == MT_INT && node.ptr.pInt != 0) RegWriteInt(node.section, node.name, *node.ptr.pInt); else if (node.type == MT_STR && node.ptr.pStr != 0) RegWriteString(node.section, node.name, node.ptr.pStr->ptr()); } #else IniHash hash; FSPath path = configDirPath; path.Push(CS_UTF8, "config"); hash.Load((sys_char_t*)path.GetString(sys_charset_id)); for (int i = 0; i<mapList.count(); i++) { Node &node = mapList[i]; if (node.type == MT_BOOL && node.ptr.pBool != 0) hash.SetBoolValue(node.section, node.name, *node.ptr.pBool); else if (node.type == MT_INT && node.ptr.pInt != 0) hash.SetIntValue(node.section, node.name, *node.ptr.pInt); else if (node.type == MT_STR && node.ptr.pStr != 0) hash.SetStrValue(node.section, node.name, node.ptr.pStr->ptr()); } hash.Save((sys_char_t*)path.GetString(sys_charset_id)); #endif }
void OperDirCalcThread::Calc() { MutexLock lock( Node().GetMutex() ); if ( !Node().Data() ) { return; } OperDirCalcData* CalcData = ( OperDirCalcData* )Node().Data(); clPtr<FS> fs = CalcData->dirFs; FSPath path = CalcData->_path; clPtr<FSList> list = CalcData->dirList; lock.Unlock(); //!!! //dbg_printf("OperDirCalcThread::Calc list data:"); //path.dbg_printf("FSPath:"); //for (FSNode* node = list->First(); node; node = node->next) // dbg_printf("%s\n", node->name.GetUtf8()); if (list->Count() == 0) { // then calculate current dir size CalcDir(fs.Ptr(), path); } else { // list is not empty: calculate size of objects in the list int cnt = path.Count(); for (FSNode* node = list->First(); node; node = node->next) { path.SetItemStr(cnt, node->Name()); //-V595 bool IsDir = node->IsDir() && !node->st.IsLnk(); if ( IsDir ) { int64_t Size = CalcDir( fs.Ptr(), path); if ( Size >= 0 && node && node->originNode ) { node->originNode->st.size = Size; } CalcData->folderCount++; } else { CalcData->fileCount++; CalcData->sumSize += node->st.size; } } } }
bool FSTmp::AddNode(FSPath& srcPath, FSNode* fsNode, FSPath& destPath) { FSPath parentDir = destPath; parentDir.Pop(); //dbg_printf("FSTmp::AddNode srcPath.Count()=%d, parentDir.Count()=%d\n", srcPath.Count(), parentDir.Count()); //srcPath.dbg_printf("FSTmp::AddNode srcPath="); //destPath.dbg_printf("FSTmp::AddNode destPath="); FSTmpNode* dn = rootDir.findByFsPath(&parentDir); if (!dn || dn->nodeType != FSTmpNode::NODE_DIR) { return false; } FSTmpNode fsTmpNode(&srcPath, &fsNode->st, dn); return dn->Add(&fsTmpNode); }
int FSSftp::SetFileTime ( FSPath& path, FSTime aTime, FSTime mTime, int* err, FSCInfo* info ) { MutexLock lock( &mutex ); int ret = CheckSession( err, info ); if ( ret ) { return ret; } struct timeval tv[2]; tv[0].tv_sec = aTime; tv[0].tv_usec = 0; tv[1].tv_sec = mTime; tv[1].tv_usec = 0; if ( sftp_utimes( sftpSession, ( char* )path.GetString( _operParam.charset ), tv ) ) { if ( err ) { *err = sftp_get_error( sftpSession ); } return -1; } return 0; }
int FSSys::OpenRead ( FSPath& path, int flags, int* err, FSCInfo* info ) { int shareFlags = 0; if ( flags & FS::SHARE_READ ) { shareFlags |= FILE_SHARE_READ; } if ( flags & FS::SHARE_WRITE ) { shareFlags |= FILE_SHARE_WRITE; } HANDLE h = CreateFileW( SysPathStr( _drive, path.GetUnicode( '\\' ) ).data(), GENERIC_READ, shareFlags, 0, OPEN_EXISTING, 0, 0 ); //file_open(SysPathStr(_drive, path.GetUnicode('\\')).ptr()); if ( h == INVALID_HANDLE_VALUE ) { SetError( err, GetLastError() ); return -1; } int fd = handles.New(); HANDLE* p = this->handles.Handle( fd ); if ( !p ) { SetError( err, ERROR_INVALID_PARAMETER ); CloseHandle( h ); return -1; } *p = h; return fd; }
int FSSftp::SetFileTime ( FSPath& path, FSTime aTime, FSTime mTime, int* err, FSCInfo* info ) { MutexLock lock( &mutex ); int ret = CheckSession( err, info ); if ( ret ) { return ret; } LIBSSH2_SFTP_ATTRIBUTES attr; attr.flags = LIBSSH2_SFTP_ATTR_ACMODTIME; attr.atime = aTime; attr.mtime = mTime; try { int ret; WHILE_EAGAIN_( ret, libssh2_sftp_setstat( sftpSession, ( char* )path.GetString( _operParam.charset, '/' ), &attr ) ); CheckSFTP( ret ); } catch ( int e ) { if ( err ) { *err = e; } return ( e == -2 ) ? -2 : -1; } return 0; }
clPtr<FS> ParzeFtpURI( const unicode_t* uri, FSPath& path, clPtr<FS>* checkFS, int count ) { path.Set( rootPathStr ); if ( !uri[0] ) { return clPtr<FS>(); } FSFtpParam param; const unicode_t* userDelimiter = FindFirstChar( uri, '@' ); if ( *userDelimiter ) { param.user = FSString( CS_UNICODE, uri, userDelimiter - uri ).GetUnicode(); uri = userDelimiter + 1; param.anonymous = false; } else { param.anonymous = true; } const unicode_t* host_port_End = FindFirstChar( uri, '/' ); const unicode_t* host_End = FindFirstChar( uri, ':' ); FSString host( CS_UNICODE, uri, ( ( host_End < host_port_End ) ? host_End : host_port_End ) - uri ); int port = 0; for ( const unicode_t* s = host_End + 1; s < host_port_End; s++ ) if ( *s >= '0' && *s <= '9' ) { port = port * 10 + ( *s - '0' ); } else { break; } if ( port > 0 && port < 65536 ) { param.port = port; } param.server = host.GetUnicode(); uri = host_port_End; FSString link = uri; if ( !ParzeLink( path, link ) ) { return clPtr<FS>(); } for ( int i = 0; i < count; i++ ) if ( checkFS[i].Ptr() && checkFS[i]->Type() == FS::FTP ) { FSFtp* p = ( FSFtp* )checkFS[i].Ptr(); FSFtpParam checkParam; p->GetParam( &checkParam ); if ( !CmpStr<const unicode_t>( param.server.Data(), checkParam.server.Data() ) && ( param.anonymous == checkParam.anonymous && ( param.anonymous || !CmpStr<const unicode_t>( param.user.Data(), checkParam.user.Data() ) ) ) && param.port == checkParam.port ) { return checkFS[i]; } } return new FSFtp( ¶m ); }
clPtr<FS> ParzeSmbURI( const unicode_t* uri, FSPath& path, clPtr<FS>* checkFS, int count ) { path.Set( rootPathStr ); if ( !uri[0] ) { return new FSSmb(); } FSSmbParam param; const unicode_t* userDelimiter = FindFirstChar( uri, '@' ); if ( *userDelimiter ) { FSString s( CS_UNICODE, uri, userDelimiter - uri ); SetString( const_cast<char*>( param.user ), sizeof( param.user ), s.GetUtf8() ); uri = userDelimiter + 1; } const unicode_t* hostEnd = FindFirstChar( uri, '/' ); FSString host( CS_UNICODE, uri, hostEnd - uri ); SetString( const_cast<char*>( param.server ), sizeof( param.server ), host.GetUtf8() ); uri = hostEnd; FSString link = uri; if ( !ParzeLink( path, link ) ) { return clPtr<FS>(); } return new FSSmb( ¶m ); }
int FSSys::OpenCreate ( FSPath& path, bool overwrite, int mode, int flags, int* err, FSCInfo* info ) { DWORD diseredAccess = GENERIC_READ | GENERIC_WRITE; DWORD shareMode = 0; DWORD creationDisposition = ( overwrite ) ? CREATE_ALWAYS : CREATE_NEW; //??? HANDLE h = CreateFileW( SysPathStr( _drive, path.GetUnicode( '\\' ) ).data(), diseredAccess, FILE_SHARE_WRITE, 0, creationDisposition, 0, 0 ); if ( h == INVALID_HANDLE_VALUE ) { SetError( err, GetLastError() ); return -1; } int fd = handles.New(); HANDLE* p = this->handles.Handle( fd ); if ( !p ) { SetError( err, ERROR_INVALID_PARAMETER ); CloseHandle( h ); return -1; } *p = h; return fd; }