本文整理汇总了C++中FSPath::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ FSPath::GetString方法的具体用法?C++ FSPath::GetString怎么用?C++ FSPath::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSPath
的用法示例。
在下文中一共展示了FSPath::GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: Rename
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;
}
示例3: 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;
}
示例4: Save
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
}
示例5: SetFileTime
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;
}
示例6: SetFileTime
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;
}
示例7: OpenRead
int FSSftp::OpenRead ( FSPath& path, int* err, FSCInfo* info )
{
MutexLock lock( &mutex );
int ret = CheckSession( err, info );
if ( ret ) { return ret; }
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_RDONLY, 0 );
if ( !f )
{
if ( err ) { *err = sftp_get_error( sftpSession ); }
return -1;
}
fileTable[n] = f;
return n;
}
示例8: 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 ;
}
}
示例9: Stat
int FSSftp::Stat ( FSPath& path, FSStat* st, int* err, FSCInfo* info )
{
MutexLock lock( &mutex );
int ret = CheckSession( err, info );
if ( ret ) { return ret; }
char* fullPath = ( char* ) path.GetString( _operParam.charset );
sftp_attributes la = sftp_lstat( sftpSession, fullPath );
if ( !la )
{
if ( err ) { *err = sftp_get_error( sftpSession ); }
return -1;
}
if ( la->type == SSH_FILEXFER_TYPE_SYMLINK )
{
char* s = sftp_readlink( sftpSession, fullPath );
if ( s ) { st->link.Set( _operParam.charset, s ); }
sftp_attributes_free( la ); //!!!
}
else
{
st->mode = la->permissions;
st->size = la->size;
st->uid = la->uid;
st->gid = la->gid;
st->mtime = la->mtime;
sftp_attributes_free( la ); //!!!
return 0;
}
sftp_attributes a = sftp_stat( sftpSession, fullPath );
if ( !a )
{
if ( err ) { *err = sftp_get_error( sftpSession ); }
return -1;
}
st->mode = la->permissions;
st->size = la->size;
st->uid = la->uid;
st->gid = la->gid;
st->mtime = la->mtime;
sftp_attributes_free( a ); //!!!
return 0;
}
示例10: OpenRead
int FSSys::OpenRead ( FSPath& path, int flags, int* err, FSCInfo* info )
{
int n = open( ( char* ) path.GetString( sys_charset_id, '/' ),
O_RDONLY | OPENFLAG_LARGEFILE, 0 );
if ( n < 0 ) { SetError( err, errno ); return -1; }
return n;
}
示例11: open
int FSSys::OpenCreate ( FSPath& path, bool overwrite, int mode, int flags, int* err, FSCInfo* info )
{
int n = open( ( char* ) path.GetString( sys_charset_id, '/' ),
O_CREAT | O_WRONLY | O_TRUNC | OPENFLAG_LARGEFILE | ( overwrite ? 0 : O_EXCL ) , mode );
if ( n < 0 ) { SetError( err, errno ); return -1; }
return n;
}
示例12: Symlink
int FSSys::Symlink( FSPath& path, FSString& str, int* err, FSCInfo* info )
{
if ( symlink( ( char* )str.Get( sys_charset_id ), ( char* )path.GetString( sys_charset_id ) ) )
{
SetError( err, errno );
return -1;
}
return 0;
}
示例13: Delete
int FSSys::Delete( FSPath& path, int* err, FSCInfo* info )
{
if ( unlink( ( char* ) path.GetString( sys_charset_id, '/' ) ) )
{
SetError( err, errno );
return -1;
}
return 0;
}
示例14: RmDir
int FSSys::RmDir( FSPath& path, int* err, FSCInfo* info )
{
if ( rmdir( ( char* ) path.GetString( sys_charset_id, '/' ) ) )
{
SetError( err, errno );
return -1;
}
return 0;
}
示例15: MkDir
int FSSys::MkDir( FSPath& path, int mode, int* err, FSCInfo* info )
{
if ( mkdir( ( char* ) path.GetString( sys_charset_id, '/' ), mode ) )
{
SetError( err, errno );
return -1;
}
return 0;
}