本文整理汇总了C++中FileList::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ FileList::Size方法的具体用法?C++ FileList::Size怎么用?C++ FileList::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileList
的用法示例。
在下文中一共展示了FileList::Size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
FileList FileList::operator+=(const FileList &list2)
{
size_t oldsize = files.size();
files.resize(oldsize + list2.Size());
for (size_t i = oldsize; i < files.size(); i++)
{
files[i] = list2[i-oldsize];
}
return *this;
}
示例2: PlatformNormalize
// used for resolving case-insensative paths to case-sensative ones
// when appropriate IsCaseSensative() = true
bool PlatformNormalize(std::string &normpath, const std::string &path, const std::string root)
{
if (!FileList::IsCaseSensative()) // windows simply returns identity
{
// should only get hit on windows
if (root[root.length()-1] != '\\')
{
normpath = root + "\\" + path;
}
else
{
normpath = root + path;
}
return true;
}
// else it's a *nix system - normalize it to / instead of \ -
FileList curdir;
normpath = root;
// break path down into it's componants
std::vector<std::string> parts;
Expand(path, '/', parts);
bool found;
for (size_t i = 0; i < parts.size(); i++)
{
curdir.GetList(normpath);
found = false;
for (size_t j = 0; j < curdir.Size(); j++)
{
if (strLower(std::string(curdir[j])) ==
strLower(std::string(parts[i])))
{
normpath += std::string("/") + curdir[j];
found = true;
break;
}
}
if (!found)
return false; //yikes
curdir.Clear();
}
return true;
}
示例3: RunFileBrowser
int RunFileBrowser(char *source, char *outname, const char *types[],
const char *info) {
int size = 0;
int index;
int offset_start, offset_end;
static int max_entries = 8;
int scrollModifier = 4;
int justsavedromdir = 0;
int scrollMult;
static int spy;
int y, i;
// Try to get a saved romdir from a config file
char* home = getenv("HOME");
char romcfgfile [128];
sprintf (romcfgfile, "%s/.fceux/romdir.cfg", home);
FILE * pFile;
pFile = fopen (romcfgfile,"r+");
if (pFile != NULL) {
fgets (s_LastDir , 128 , pFile);
fclose (pFile);
}
// Create file list
FileList *list = new FileList(source ? source : s_LastDir, types);
if (list == NULL)
return 0;
scrollModifier *= max_entries;
RESTART:
spy = 72;
size = list->Size();
index = 0;
offset_start = 0;
offset_end = size > max_entries ? max_entries : size;
g_dirty = 1;
while (1) {
// Parse input
readkey();
// TODO - put exit keys
// Go to previous folder or return ...
if (parsekey(DINGOO_B)) {
list->Enter(-1);
goto RESTART;
}
// Enter folder or select rom ...
if (parsekey(DINGOO_A)) {
if (list->GetSize(index) == -1) {
list->Enter(index);
goto RESTART;
} else {
strncpy(outname, list->GetPath(index), 128);
break;
}
}
if (parsekey(DINGOO_X)) {
return 0;
}
if (parsekey(DINGOO_SELECT)) {
// Save the current romdir in a config file
char* home = getenv("HOME");
char romcfgfile [128];
strncpy(s_LastDir, list->GetCurDir(), 128);
sprintf (romcfgfile, "%s/.fceux/romdir.cfg", home);
FILE * pFile;
pFile = fopen (romcfgfile,"w+");
fputs (s_LastDir,pFile);
fclose (pFile);
justsavedromdir = 1;
}
if (size > 0) {
// Move through file list
if (parsekey(DINGOO_R, 0)) {
index = size - 1;
spy = 72 + 15*(max_entries-1);
offset_end = size;
offset_start = offset_end - max_entries;
}
if (parsekey(DINGOO_L, 0)) {
goto RESTART;
}
if (parsekey(DINGOO_UP, 1)) {
//.........这里部分代码省略.........
示例4: _Make
int Book::_Make( const char* dir, int max, ADD_METHOD method ){
/************************************************
定跡の作成
************************************************/
Shogi* pshogi;
MOVE move;
uint64 hash;
int num = 0;
FileList flist;
string fname;
KIFU_INFO kinfo;
// ファイルの列挙
if( 0 == flist.Enumerate( dir, "csa" ) ){
cerr << "Error!" << '\n';
return 0;
}
pshogi = new Shogi( HIRATE );
cerr << "Make a book.." << '\n';
while( flist.Pop( fname ) ){
if( 0 == pshogi->InputFileCSA( fname.c_str(), &kinfo ) ){
continue;
}
num++;
// 棋譜の最後かどうか
#if 1
bool is_last = true;
#endif
// 定跡登録
while( pshogi->GetMove( move ) && pshogi->GoBack() ){
// 勝った側の指し手だけを採用する。 2011/03/13
#if 1
if( is_last ){
// 初回は1手だけ戻す。
// 最後に指した方が勝ったはず。
is_last = false;
}
else{
// それ以外は2手ずつ戻す。
if( !( pshogi->GetMove( move ) && pshogi->GoBack() ) ){
break;
}
}
#endif
// 指定した手数より手前なら登録
if( pshogi->GetNumber() < max ){
hash = pshogi->GetHash();
switch( method ){
case OVER_WRITE:
Add( hash, move, OVER_WRITE, 1 );
break;
case ADD_NEW:
Add( hash, move, ADD_NEW, 1, kinfo.start.export_date() );
break;
default:
Add( hash, move, OVER_WRITE, 1 );
break;
}
}
}
// 進捗表示
Progress::Print( num * 100 / flist.Size() );
}
// 進捗表示終了
Progress::Clear();
cerr << "Number of files : " << num << '\n';
delete pshogi;
return 1;
}