本文整理汇总了C++中FileList::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ FileList::GetName方法的具体用法?C++ FileList::GetName怎么用?C++ FileList::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileList
的用法示例。
在下文中一共展示了FileList::GetName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int agv,char *agc[])
{
char lstname[256],dataname[256];
if (agv==1) {
printf("Need Argument\n");
return -1;
}
if (agc[1][0]=='x') {
char filename[256];
int i;
strcpy(lstname,agc[2]);
strcpy(dataname,agc[2]);
strcat(lstname,".lst");
strcat(dataname,".wdf");
if (!file_exist(lstname)) {
printf("Can't open list file[.lst]\n");
return -1;
}
if (!file_exist(dataname)) {
printf("Can't open data file[.wdf]\n");
return -1;
}
_mkdir(agc[2]);
FileList list;
int n;
n=list.ReadListOnly(lstname);
std::vector<FILE_LST> old_list;
int old_number=read_lst(dataname,old_list);
FILE *df;
df=fopen(dataname,"rb");
for (i=0;i<n;i++) {
FILE *f;
int j;
static char buffer[1024];
strcpy(filename,agc[2]);
strcat(filename,"\\");
int n;
n=list.IsFileExist(i,old_list,old_number);
printf("%s [%x] ",list.GetName(i),list.GetID(i));
if (n<0) {
printf(" Can't find\n");
continue;
}
strcat(filename,list.GetName(i));
char *path=strchr(filename,'\\');
path=strchr(path+1,'\\');
if (path) {
path[0]=0;
_mkdir(filename);
path[0]='\\';
}
f=fopen(filename,"wb");
fseek(df,old_list[n].offset,SEEK_SET);
for (j=0;j<old_list[n].size-1024;j+=1024) {
fread(buffer,1,1024,df);
fwrite(buffer,1,1024,f);
}
j=old_list[n].size-j;
fread(buffer,1,j,df);
fwrite(buffer,1,j,f);
fclose(f);
printf(" Extracted\n");
}
fclose(df);
return 0;
}
strcpy(lstname,agc[1]);
strcpy(dataname,agc[1]);
strcat(lstname,".lst");
strcat(dataname,".wdf");
if (!file_exist(lstname)) {
printf("Can't open list file[.lst]\n");
return -1;
}
if (file_exist(dataname)) {
printf("Updating Data File...\n");
update_datafile(dataname,lstname);
}
else {
printf("Creating New Data File...\n");
create_new(dataname,lstname);
}
return 0;
}
示例2: RunFileBrowser
//.........这里部分代码省略.........
index = 0;
offset_start = 0;
offset_end = size <= max_entries ? size : max_entries;
spy = 72;
}
}
if (parsekey(DINGOO_LEFT, 1)) {
if (index > offset_start) {
index = offset_start;
spy = 72;
} else if (index - scrollModifier >= 0){
index -= scrollModifier;
offset_start -= scrollModifier;
offset_end = offset_start + max_entries;
} else
goto RESTART;
}
if (parsekey(DINGOO_RIGHT, 1)) {
if (index < offset_end-1) {
index = offset_end-1;
spy = 72 + 15*(index-offset_start);
} else if (offset_end + scrollModifier <= size) {
index += scrollModifier;
offset_end += scrollModifier;
offset_start += scrollModifier;
} else {
index = size - 1;
spy = 72 + 15*(max_entries-1);
offset_end = size;
offset_start = offset_end - max_entries;
}
}
}
// Draw stuff
if (g_dirty) {
draw_bg(g_bg);
//Draw Top and Bottom Bars
DrawChar(gui_screen, SP_SELECTOR, 0, 37);
DrawChar(gui_screen, SP_SELECTOR, 81, 37);
DrawChar(gui_screen, SP_SELECTOR, 0, 225);
DrawChar(gui_screen, SP_SELECTOR, 81, 225);
DrawText(gui_screen, "B - Go Back", 235, 225);
DrawChar(gui_screen, SP_LOGO, 12, 9);
// Draw selector
DrawChar(gui_screen, SP_SELECTOR, 4, spy);
DrawChar(gui_screen, SP_SELECTOR, 81, spy);
DrawText(gui_screen, "ROM Browser", 8, 37);
// Draw file list
for (i = offset_start, y = 72; i < offset_end; i++, y += 15) {
DrawText(gui_screen, list->GetName(i), 8, y);
}
// Draw info
if (info)
DrawText(gui_screen, info, 8, 225);
else {
if (justsavedromdir == 1){
DrawText(gui_screen, "ROM dir successfully saved!", 8, 225);
} else {
if (list->GetSize(index) == -1)
DrawText(gui_screen, "SELECT - Save ROM dir", 8, 225);
else
DrawText(gui_screen, "SELECT - Save ROM dir", 8, 225);
}
justsavedromdir = 0;
}
// Draw offset marks
if (offset_start > 0)
DrawChar(gui_screen, SP_UPARROW, 157, 57);
if (offset_end < list->Size())
DrawChar(gui_screen, SP_DOWNARROW, 157, 197);
g_dirty = 0;
}
SDL_Delay(4);
// Update real screen
FCEUGUI_Flip();
}
if (source == NULL)
strncpy(s_LastDir, list->GetCurDir(), 128);
delete list;
return 1;
}
示例3: update_datafile
void update_datafile(const char *dataname,const char *lstname)
{
int old_number,new_number;
std::vector<FILE_LST> old_list(c_MaxFile);
old_number=read_lst(dataname,old_list);
if (old_number<0) {
printf("[%s] is Bad\n",dataname);
return;
}
FILE *f;
FileList list;
FileHeader header;
int i;
new_number=list.ReadList(lstname);
f=fopen(dataname,"rb+");
if (f==0) {
printf("[%s] can't update",dataname);
return;
}
list.ReadHeader(f,&header);
header.number=new_number;
int s;
for (s=i=0;i<old_number;i++) {
if (list.FindFile(old_list[i].uid)==-1) {
printf("A file[%x] (%d bytes) is deleted\n",old_list[i].uid,old_list[i].size);
delete_file(f,old_number,old_list,i);
++s;
}
}
if (s>0) {
printf("%d files deleted\n",s);
}
for (i=0;i<old_number;i++) {
int n;
if (old_list[i].uid==0) continue;
n=list.FindFile(old_list[i].uid);
assert(n>=0);
int space=old_list[i].size+old_list[i].space;
int size=file_size(list.GetName(n));
if (size>space) {
delete_file(f,old_number,old_list,i);
printf("[%s] deleted\n",list.GetName(n));
}
else if (size==old_list[i].size) {
if (list.NeedUpdate(f,n,old_list,i)) {
list.UpdateFile(f,n,old_list,i);
}
}
else if (size<=space) {
list.UpdateFile(f,n,old_list,i);
}
}
// 寻找文件尾
for (i=0;i<old_number;i++) {
if (old_list[i].uid==0)
continue;
if (old_list[i].offset+old_list[i].size+old_list[i].space==header.offset)
break;
}
if (i<old_number) {
header.offset=old_list[i].offset+old_list[i].size;
old_list[i].space=0;
list.ClearTail(old_list[i].uid);
}
fseek(f,header.offset,SEEK_SET);
for (i=0;i<new_number;i++) {
if (list.WriteFile(f,i,true))
printf("Added\n"); // 添加文件(见缝插针)
}
header.offset=ftell(f);
list.WriteList(f);
write_header(f,&header);
fclose(f);
}