本文整理汇总了C++中FSPath类的典型用法代码示例。如果您正苦于以下问题:C++ FSPath类的具体用法?C++ FSPath怎么用?C++ FSPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FSPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateDirectory
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() );
}
}
}
示例2: LoadToTempFile
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;
}
示例3: DeleteList
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;
}
示例4: SaveStringList
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 ;
}
}
示例5: DeleteListRecursively
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;
}
示例6: Delete
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);;
}
}
示例7: Stat
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;
}
示例8: ArchOpen
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 );
}
示例9: goRoot
void FileSystem::chmkdir(FSPath &path)
{
goRoot();
for (FSPath::iterator it = path.begin(); it != path.end(); it++)
chmkdir(it->c_str());
}
示例10: testFS
void testFS()
{
FileSystem fs;
fs.root().dump(cout);
cout << "\n";
FSPath pwd = fs.pwdir();
pwd.dump(cout);
cout << "\n";
}
示例11: Rename
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;
}
示例12: OpenCreate
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;
}
示例13: MkDir
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);
}
示例14: stripPathFromLastItem
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));
}
}
}
示例15: pwdir
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;
}