Пример #1
0
static int listpath(const char *name, int flags)
{
    struct stat s;
    int err;

    /*
     * If the name ends in a '/', use stat() so we treat it like a
     * directory even if it's a symlink.
     */
    if (name[strlen(name)-1] == '/')
        err = stat(name, &s);
    else
        err = lstat(name, &s);

    if (err < 0) {
        perror(name);
        return -1;
    }

    if ((flags & LIST_DIRECTORIES) == 0 && S_ISDIR(s.st_mode)) {
        if (flags & LIST_RECURSIVE)
            printf("\n%s:\n", name);
        return listdir(name, flags);
    } else {
        /* yeah this calls stat() again*/
        return listfile(NULL, name, flags);
    }
}
Пример #2
0
void deleteDB()
{
    system("cls");
    listfile(".\\db\\");
    char dbn[200] = ".\\db\\";

    printf("\n\n\tWhich database do you want to delete : ");
    scanf("%s",input);
    strcat(dbn,input);
    remove(strcat(dbn,".txt"));
    printf("\n\tDelete Complete");

}
Пример #3
0
void get_list(const char* filename, vector<string>& listset) {
	ifstream listfile(filename);
	if(! listfile){
	  cerr<<"No such file "<< filename<<'\n';
	  exit(0);
	}
	string line;
	while(getline(listfile, line)) {
		if(line != "") {
			listset.push_back(line);
		}
	}
}
Пример #4
0
/*
 * Read the method list file and return it is a vector of strings.
 */
std::vector<std::string> ConfigFiles::load_coldstart_methods() {
  std::ifstream listfile(m_coldstart_method_filename);
  if (!listfile) {
    fprintf(stderr, "Failed to open coldstart method list: `%s'\n",
            m_coldstart_method_filename.c_str());
    return std::vector<std::string>();
  }
  std::vector<std::string> coldstart_methods;
  std::string method;
  while (std::getline(listfile, method)) {
    if (method.length() > 0) {
      coldstart_methods.push_back(m_proguard_map.translate_method(method));
    }
  }
  return coldstart_methods;
}
Пример #5
0
int main(int argc, char * argv[])
{
	DIR *d;
	struct dirent * info; // a directory entry

	if (argc != 2)
	{
		fprintf(stderr, "usage: listdir dirname\n");
			exit(1);
	}
	chdir(argv[1]);
	d = opendir(".");

	while((info = readdir(d)) != NULL) {
		listfile(info->d_name);
	}
}
Пример #6
0
void processcommand( char *command, char *P1, char *P2, char *P3 ) {

    if( strcmp(command, "createvfs") == 0 ) {
        int size = atoi(P2);
        if( (0 == strcmp(P1,"")) || 0 == P2 ) {
            printf("createvfs_FAILURE %s \n",ERR_VFS_CREATE_00);
        } else {
            createvfs (P1,size);
        }
    }
    else if( strcmp(command, "mountvfs") == 0 ) {
        if( (0 == strcmp(P1,"")) ) {
            printf("mountvfs_FAILURE %s \n",ERR_VFS_MOUNT_05);
        } else {
            if( 1 == ui_mountFlag ) {
                printf("mountvfs_FAILURE %s \n",ERR_VFS_MOUNT_04);
            } else {
                mountvfs (P1);
            }
        }
    }
    else if( strcmp(command, "unmountvfs") == 0 ) {
        if( (0 == strcmp(P1,"")) ) {
            printf("unmountvfs_FAILURE %s \n",ERR_VFS_UNMOUNT_00);
        } else {
            if( 0 == ui_mountFlag ) {
                printf("unmountvfs_FAILURE %s \n",ERR_VFS_UNMOUNT_04);
            } else {
                unmountvfs (P1);
            }
        }
    }
    else if( strcmp(command, "makedir") == 0 ) {
        if( (0 == strcmp(P1,"")) || (0 == strcmp(P2,"")) ) {
            printf("makedir_FAILURE %s \n",ERR_VFS_MAKEDIR_00);
        } else {
            if( 0 == ui_mountFlag ) {
                printf("makedir_FAILURE %s \n",ERR_VFS_MAKEDIR_05);
            } else {
                makedir (P1,P2);
            }
        }
    }
    else if( strcmp(command, "deletedir") == 0 )
        deletedir (P1);
    else if( strcmp(command, "movedir") == 0 )
        movedir (P1,P2);
    else if( strcmp(command, "listdir") == 0 ) {
        int flag = atoi(P2);
        listdir (P1,flag,P3);
    }
    else if( strcmp(command, "addfile") == 0 )
        addfile (P1,P2,P3);
    else if( strcmp(command, "listfile") == 0 )
        listfile (P1,P2);
    else if( strcmp(command, "updatefile") == 0 )
        updatefile (P1,P2);
    else if( strcmp(command, "removefile") == 0 )
        removefile (P1);
    else if( strcmp(command, "movefile") == 0 )
        movefile (P1,P2);
    else if( strcmp(command, "copyfile") == 0 )
        copyfile (P1,P2);
    else if( strcmp(command, "exportfile") == 0 )
        exportfile (P1,P2);
    else if( strcmp(command, "searchfile") == 0 )
        searchfile (P1,P2);
    else
        printf("Ignoring invalid command %s\n", command);
}
Пример #7
0
int main(int argc , char* argv[])
{
    if (88 == initial_arg(argc , argv))
        return 88;

    char AppPath[MAX_PATH] = {0};
    GetAppDir(AppPath);

    string date_txt = string(AppPath) + "\\date.txt";
    string listfile_txt = string(AppPath) + "\\listfile.txt";

    if (_chdir(Path_Argv.c_str())) {
        printf("无法找到的目录: %s\n\a\n\n", Path_Argv.c_str());
        print_help();
        if (argc == 1) getchar();
        return -1;
    } else if (!Direct_Datelog_Flag) {
        printf("正在扫描目录: %s\n", Path_Argv.c_str());
        // 获得文件名和路径数据输入文件 ,和差不多DIR . /S /AA /TW >\date.txt
        int file_sum = find_path_save_file(Path_Argv.c_str(), date_txt.c_str());
        printf("扫描文件总数量: %d 个文件\t" , file_sum);
    }

    ifstream datefile(date_txt.c_str());
    ofstream listfile(listfile_txt.c_str());

    string readline;    // 读取每行,然后使用正则搜索匹配
    smatch m;
    regex e(Reg_Argv);

    F_STRUCT d_file ;  // 简单的文件属性结构
    map<string, string> mss_date;
    size_t file_size_sum = 0 ;

    while (getline(datefile , readline)) {
        char buf[MAX_PATH * 2];
        char* pch = NULL;
        if (regex_search(readline, m, e)) {      // 符合条件的的文件列表存如容器
            //  sscanf(readline.c_str() + 32 , "%s | %s" ,  d_file.name, d_file.path);  // 不能处理路径和文件名中有空格
            sscanf(readline.c_str() + 20 , "%d" , &d_file.size);  file_size_sum += d_file.size;
            sprintf(buf, "%s", readline.c_str() + 32);

            pch = strchr(buf, '|'); // 查找分割标记
            if (pch != NULL) {
                *pch = '\0';
                strcpy(d_file.name , buf);
                strcpy(d_file.path , pch + 1);

                csTrim(d_file.name);  csTrim(d_file.path); // 删除前后空格
                mss_date.insert(make_pair(string(d_file.path) + "\\" + d_file.name  , string(d_file.name)));
            }
        }
    }
    printf("符合条件文件数量: %d 个文件  大小: %d字节\n" , mss_date.size() , file_size_sum);
    for (auto it = mss_date.begin() ; it != mss_date.end(); ++it)
        listfile << it->first.substr(it->first.find(":\\") + 2) << "\n"; // 输出结果

    datefile.close();  listfile.close();

    // 调用7z命令行打包文件,
    string pkcmd = string("7z.exe a -scsWIN  ") + Packfile_Argv + " @" + listfile_txt;

    if (IsFileExist((string(AppPath) + "\\res\\7z.exe").c_str()))
        pkcmd = string(AppPath) + "\\res\\" + pkcmd;
    if (Test_List_Flag) pkcmd = string("TYPE ") + listfile_txt;   // 只是显示 listfiel.txt, 不打包文件

    _chdir("\\"); system("COLOR F9");
    if (system(pkcmd.c_str()) != 0) {
        fprintf(stdout, "%s\t%s %s\n" , "调用打包命令:" , pkcmd.c_str(), "失败!请检查软件目录下是否有 7z.exe");
    }
    print_help();
    if (Delete_Datelog_Flag) {
        remove(date_txt.c_str());   remove(listfile_txt.c_str());
    }
    if (argc == 1) getchar();

    return 0;
}
Пример #8
0
static int listdir(const char *name, int flags)
{
    char tmp[4096];
    DIR *d;
    struct dirent *de;
    
    d = opendir(name);
    if(d == 0) {
        fprintf(stderr, "opendir failed, %s\n", strerror(errno));
        return -1;
    }

    while((de = readdir(d)) != 0){
        if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) continue;
        if(de->d_name[0] == '.' && (flags & LIST_ALL) == 0) continue;

        listfile(name, de->d_name, flags);
    }

    if (flags & LIST_RECURSIVE) {
        rewinddir(d);

        while ((de = readdir(d)) != 0) {
            struct stat s;
            int err;

            if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
                continue;
            if (de->d_name[0] == '.' && (flags & LIST_ALL) == 0)
                continue;

            if (!strcmp(name, "/"))
                snprintf(tmp, sizeof(tmp), "/%s", de->d_name);
            else
                snprintf(tmp, sizeof(tmp), "%s/%s", name, de->d_name);

            /*
             * If the name ends in a '/', use stat() so we treat it like a
             * directory even if it's a symlink.
             */
            if (tmp[strlen(tmp)-1] == '/')
                err = stat(tmp, &s);
            else
                err = lstat(tmp, &s);

            if (err < 0) {
                perror(tmp);
                closedir(d);
                return -1;
            }

            if (S_ISDIR(s.st_mode)) {
                printf("\n%s:\n", tmp);
                listdir(tmp, flags);
            }
        }
    }

    closedir(d);
    return 0;
}
Пример #9
0
void createTable(char mode[], char path[])
{
    system("cls");
    int i, j, k, n, qNum, tableNum, attribute[100], row[100], letterCount=0;
    char table[100][100], attName[100][100][100], field[100][100][100], x[50000];
    char y[100];
    char DBName[100];
    char dbn[200] = ".\\db\\";


    if(strcmp(mode,"CREATED"))
    {
        listfile(".\\db\\");
        printf("\n\tDatabase Name : ");
        //gets(DBName);
        gets(y);
    }
    else if(!strcmp(mode,"CREATED") && strcmp(path," "))
    {
        //gets(DBName);
        strcpy(y,path);
    }
    strcat(dbn,y);

    if((fpt = fopen(strcat(dbn,".txt"),"a")) == NULL)
    {
        perror("\n\tError reading database, please try again or read the manual.\n\n");
        system("PAUSE");
        exit(1);
    }
    i = j = k = qNum = 0;
    do
    {
        qNum++;
        printf("\n\tTable name : ");
        gets(table[i]);

        attribute[i] = 0;
        do
        {
            attribute[i]++;
            printf("\n\tAttribute %d : ", j+1);
            gets(attName[i][j]);
            printf("\n\tAdd more Attribute? [y/n]: ");
            j++;
        }
        while(getche() == 'y');
        row[i] = j = n = 0;
        do
        {
            row[i]++;
            for(k = 0; k < attribute[i]; k++)
            {
                printf("\n\tRow %d's %s  : ", j+1, attName[i][k]);
                gets(field[i][n]);
                n++;
            }
            printf("\n\tAdd another Row? [y/n]: ");
            j++;
        }
        while(getche() == 'y');
        printf("\n\tPress any key to continue . . . ");
        i++;
    }
    while(getche() == 'Y');
    //printf("sssss\n");
    for(i = 0; i < qNum; i++)
    {
        fprintf(fpt,"TABLE%s\n",table[i]);
        fprintf(fpt,"ATTRIBUTE %d\n",attribute[i]);
        for(j = 0; j < attribute[i]; j++)
        {
            fprintf(fpt,"%s\n",attName[i][j]);
        }
        fprintf(fpt,"ROW %d\n",row[i]);
        n = 0;
        for(j = 0; j < row[i]; j++)
        {
            for(k = 0; k < attribute[i]; k++)
            {
                fprintf(fpt,"%s ",field[i][n]);
                n++;
            }
            fprintf(fpt,"\n");
        }
    }
    fclose(fpt);
}
Пример #10
0
void readDB(char mode[])
{

    int i, j, k, n, AttNum, RowNum, TableNum, qNum;
    char DBName[100], table[100][100], db[100][100][100], Attribute[50][100], x[100];
    char b[100];


    listfile(".\\db\\");
    printf("\n\tSelect a Database: ");
    gets(DBName);

    i = k = qNum = 0;
    if(!strcmp(mode,"SELECT"))
    {
        do
        {
            qNum++;
            printf("\n\tWhich table? : ");
            gets(table[i]);
            printf("\n\tJoin another table? [y/n]: ");
            i++;
        }
        while(getche() == 'y');
    }

    char dbn[200] = ".\\db\\";
    strcat(dbn,DBName);


    if((fpt = fopen(strcat(dbn,".txt"),"r")) == NULL)
    {
        //printf("\n%s",path);
        perror("\n\tError reading database, please try again or read the manual.\n\n");
        system("PAUSE");
        exit(1);
    }
    else
    {
        if(!strcmp(mode,"SELECT"))
        {
            for(k = 0; k < qNum; k++)
            {
                rewind(fpt);
                //printf("\nseeked");
                //find the desired table
                char t[100] = "TABLE";

                strcat(t,table[k]);

                while(strcmp(x,t))
                {
                    fscanf(fpt,"%s",x);
                }
                //printf("\nFound Table");

                //Get number of Attribute
                fscanf(fpt,"%s %d\n",x,&AttNum);
                //printf("\nGot AttNum");

                printf("\n");
                //Get Attributes's names
                for(i = 0; i < AttNum; i++)
                {
                    fscanf(fpt,"%s\n",Attribute[i]);
                }

                //Get Number of Row(s)
                fscanf(fpt,"%s %d\n",x,&RowNum);

                //Get Fields
                for(i = 0; i < RowNum; i++)
                {
                    for(j = 0; j < AttNum; j++)
                    {
                        fscanf(fpt,"%s ",db[i][j]);
                    }
                    fscanf(fpt,"\n");
                }
                int l;
                /*l = strlen(table[k]);
                for(i = 0; i < l; i++)
                {
                    table[k][i] = table[k][i+5];
                }
                table[k][l] = ('\0');*/
                printf("\t+++%s+++\n\n",table[k]);
                //Print Attributes
                for(i = 0; i < AttNum; i++)
                {
                    printf("\t");
                    //Extra from NeunG
                    printf("%-16s", Attribute[i]);
                }
                printf("\n\t----------------------------------------------------\n");

                //Prints Rows of Data
                for(i = 0; i < RowNum; i++)
                {
                    for(j = 0; j < AttNum; j++)
                    {
                        printf("\t");
                        //Extra from NeunG
                        printf("%-16s",db[i][j]);
                    }
                    printf("\n");
                }
            }
            fclose(fpt);
        }
        else if(!strcmp(mode,"ALL"))
        {
            //Get number of table(s)
            fscanf(fpt,"%s %d\n",x,&TableNum);
            qNum = TableNum;
            //printf("%d\n",TableNum);


            for(k = 0; k < qNum; k++)
            {
                fscanf(fpt,"%s\n",table[k]);
                int l;
                l = strlen(table[k]);
                for(i = 0; i < l; i++)
                {
                    table[k][i] = table[k][i+5];
                }
                table[k][l] = ('\0');
                //Get number of Attribute
                fscanf(fpt,"%s %d\n",x,&AttNum);
                //printf("\nGot AttNum=%d\n",AttNum);

                printf("\n");
                //Get Attributes's names
                for(i = 0; i < AttNum; i++)
                {
                    fscanf(fpt,"%s\n",Attribute[i]);
                }
                //printf("GotAttName\n");

                //Get Number of Row(s)
                fscanf(fpt,"%s %d\n",x,&RowNum);
                //printf("GotRowNum=%d\n",RowNum);
                //getch();

                //Get Fields

                for(i = 0; i < RowNum; i++)
                {
                    for(j = 0; j < AttNum; j++)
                    {
                        fscanf(fpt,"%s ",db[i][j]);
                        //printf("gotAField\n");
                    }
                    fscanf(fpt,"\n");
                }
                printf("\t+++%s+++\n\n",table[k]);
                //Print Attributes
                for(i = 0; i < AttNum; i++)
                {
                    printf("\t");
                    //Extra from NeunG
                    printf("%-16s", Attribute[i]);
                }
                printf("\n\t----------------------------------------------------\n");

                //Prints Rows of Data
                for(i = 0; i < RowNum; i++)
                {
                    for(j = 0; j < AttNum; j++)
                    {
                        printf("\t");
                        //Extra from NeunG
                        printf("%-16s",db[i][j]);
                    }
                    printf("\n");
                }
            }
            fclose(fpt);
        }

    }
}
Пример #11
0
void deleteTable()
{
    system("cls");
    struct delTable
    {
        char nameTable[30];
        char Attribute[30][200];
        int numAt;
        char row[30][200];
        int numRow;
    } info[10],temp;


    int numTable,i,j;
    char Delwant[30];
    char Tnum[100],x[30];
    char Table[30] = "TABLE";
    char DBName[30];
    char dbn[200] = ".\\db\\";

    listfile(".\\db\\");
    printf("\n\n\tDatabase name to delete : ");
    gets(DBName);
    strcat(dbn,DBName);

    if((fpt = fopen(strcat(dbn,".txt"),"r")) == NULL)
    {
        printf("Error creating new file, please try again or read the manual.");
        system("PAUSE");
        exit(1);
    }
    else
    {
        fscanf(fpt,"%s %d\n",Tnum,&numTable);

        for(i=0; i<numTable; i++)
        {
            fscanf(fpt,"%s\n",info[i].nameTable);
            fscanf(fpt,"%s %d\n",x,&info[i].numAt);
            for(j=0; j<info[i].numAt; j++)
            {
                fscanf(fpt,"%s\n",info[i].Attribute[j]);
            }
            fscanf(fpt,"%s %d\n",x,&info[i].numRow);
            for(j=0; j<info[i].numRow*info[i].numAt; j++)
            {
                fscanf(fpt,"%s",info[i].row[j]);
            }
        }
        fclose(fpt);
        printf("\n\tWhich table do you want to delete : ");
        gets(Delwant);
        strcat(Table,Delwant);
        for(i=0; i<numTable-1; i++)
        {
            if(strcmp(Table,info[i].nameTable)==0)
            {
                temp=info[i];
                info[i]=info[i+1];
                info[i+1]=temp;
            }

        }
        fpt = fopen(dbn,"w");
        fprintf(fpt,"TNUM %d\n",numTable-1);
        for(i=0; i<numTable-1; i++)
        {
            fprintf(fpt,"%s\n",info[i].nameTable);
            fprintf(fpt,"ATTRIBUTE %d\n",info[i].numAt);
            for(j=0; j<info[i].numAt; j++)
            {
                fprintf(fpt,"%s\n",info[i].Attribute[j]);
            }
            fprintf(fpt,"ROW %d\n",info[i].numRow);
            for(j=0; j<info[i].numAt*info[i].numRow; j++)
            {
                fprintf(fpt,"%s ",info[i].row[j]);
                if((j+1)%info[i].numAt==0)
                {
                    fprintf(fpt,"\n");
                }
            }
        }
        fclose(fpt);


    }
    printf("\n\tComplete");
    Sleep(200);
}
Пример #12
0
    void CIFTREE_extract(std::ifstream & inFile, std::vector<Her::CIFTREE_idxEntry> jumpList, std::string outdir) {
        //// DECOMPRESS

        std::vector<uint8_t> outData;
        std::ostringstream outName;
        std::string outSuffix;
        std::ofstream outFile;

        std::map<std::string, std::string> extlist;

        int nWidth = (int)std::log10(jumpList.size())+1; // for zero-padding

        // we want the CIFLIST first, regardless of position in the tree, and
        // get the proper file extensions
        for (auto & i : jumpList) {
            if (i.fileName != "CIFLIST") {
                continue;
            }

            outData = ctext(i, inFile);

            std::string listfile((char*)outData.data(), outData.size());

            extlist = getexts(listfile);

            break; // we've gone through CIFLIST, nothing more to do here.
        }

        // now to actually process these files
        for (auto &i : jumpList) {
            outData = ctext(i, inFile);

            // handle TGA files if necessary
            if (i.fileType == 2) { // PLAIN (image)
                // XXX DECAL type probably doesn't hit this; should it?
                outData = Her::make_TGA(outData, i.xorigin, i.yorigin, i.imgWidth, i.imgHeight);
            }

            // figure out the extension
            try {
                outSuffix = extlist.at(i.fileName);
            } catch(std::exception & err) {
                std::cerr << "C++ ERROR: \n" << err.what() << "\n";
                std::cerr << "(Additional info:)\nTried \"" << i.fileName << "\" (" << i.fileName.size() << ")\n";
                throw 42;
            }

            // create path to save to
            outName << std::setw(nWidth) << std::setfill('0') << i.fileNo;
            outName << "_" << std::string(i.fileName.c_str()); // kill the null padding
            outName << outSuffix; // not using outSuffix to makeoutfile 'cos it currently segfaults, seemingly on path.stem, or something it does?

            // create filehandle and save
            outFile.open(Her::makeoutfile(outName.str(), outdir), std::ios::binary | std::ios::out);
            outFile.write((char*)(outData.data()), outData.size());
            outFile.close();

            // empty other variables
            outName.clear(); outName.str("");
            outData.clear();
        }
    }
Пример #13
0
void * listfile(SINT cmd,LONG info,CHAR *str)
{
	#define	 MAX_X 20
	#define	 MAX_Y 30

	static struct WINSCR buf[MAX_Y];
	static struct WS_INFO ws;

	LONG a;
	LONG pt;

	static SINT IptMirror;
	static SINT scrhdl=-1;
	//struct ffblk file;
	FFBLK Fblk;
	SINT fine;
	static CHAR *p,*pmem=NULL;
	static CHAR extcur[4];
	//WORD sgm;
	CHAR serv[255];

	CHAR Bsys.szMouseCursorName[NOMEICONE_SIZE+1]; // Icone corrente del mouse
	SINT BMS_ax,BMS_ay;

	//-------------------------------------------------

	if (cmd==WS_INF) return &ws;
	switch (cmd) {

	case WS_BUF : //			  			Richiesta buffer

				if (scrhdl==-1) break;
				for (a=0;a<ws.numcam;a++) {
				 pt=a+ws.offset; if (pt>=ws.maxcam) break;
				 buf[(SINT) a].keypt=(CHAR *) (pmem+((SINT) pt*MAX_X));
				}
				break;

	case WS_OFF : //			  												Settaggio offset

				ws.offset=info;
				break;

	case WS_KEYPRESS :
				if (key_press(9)||key_press2(_FDX)) strcpy(str,"ESC:->");
				if (key_press2(15)||key_press2(_FSX)) strcpy(str,"ESC:<-");
				//if (key_press(9)) strcpy(str,"ESC:->");
				//if (key_press2(15)) strcpy(str,"ESC:<-");
				break;


	case WS_FINDKEY :
	case WS_FIND : //			  						Ricerca la Chiave selezionata

				if (scrhdl==-1) break;

				strupr(str);
				a=ws.selez+1;

				if (memcmp(str,pmem+((SINT) a*MAX_X),strlen(str))==0)
						{listfile(WS_OFF,a,"");
						 if (ws.offset>(ws.maxcam-ws.numcam))
								 ws.offset=(ws.maxcam-ws.numcam);
						 if (ws.offset<0) ws.offset=0;
						 listfile(WS_SEL,a,"");
						 break;}
				{

				for(a=0;a<ws.maxcam;a++)
				{
				 if (memcmp(str,pmem+((SINT) a*MAX_X),strlen(str))<=0)
						{listfile(WS_OFF,a,"");
						 if (ws.offset>(ws.maxcam-ws.numcam))
								{ws.offset=(ws.maxcam-ws.numcam);}
						 if (ws.offset<0) ws.offset=0;
						 listfile(WS_SEL,a,"");
						 break;}
				 }
				}
				break;

	case WS_SEL : //			  			Settaggio selez

				ws.selez=info;

				if ((info>-1)&&IptMirror)
					{ipt_write(1,(CHAR *) (pmem+((SINT) info*MAX_X)),0);
					 ipt_vedisolo(1);
					 }

				//sonic(2000,1,1,1,1,6); //ehSleep(30);
				break;

	case WS_PTREC : //			  			Restituisce pt alla chiave selezionata

				buf[0].record=ws.selez;
				buf[0].keypt=(CHAR *) (pmem+((SINT) ws.selez*MAX_X));
				break;


	case WS_REFON : //			  			       Richiesta di refresh schermo

				ws.refre=ON;
				break;

	case WS_REFOFF : //			  											 Schermo rifreshato

				ws.refre=OFF;
				break;

	case WS_OPEN : //														  PREPARA I DATI

				if ((info<4)||(info>MAX_Y))
						{
						ehExit("Errore di assegnazione campi in listfile");
						}

				ws.sizecam=MAX_X;
				ws.numcam=info;// Assegna il numero di campi da visualizzare

	case WS_LOAD :

				if (scrhdl>-1) memoFree(scrhdl,"Cr2");// Libera la memoria

				scrhdl=-1;
				ws.maxcam=0;
				ws.offset=0;
				ws.selez=-1;
				ws.koffset=-1;
				ws.kselez=-1;
				ws.dispext=ON;
				ws.refre=ON;

				//	Conta i file
				strcpy(serv,PathNow);
				strcat(serv,"*.");
				strcat(serv,extcur); //strcat(serv,extcur);

				// Cambia il mouse
				strcpy(Bsys.szMouseCursorName,sys.szMouseCursorName);
				BMS_ax=MS_ax; BMS_ay=MS_ay;
				mouse_graph(0,0,"CLEX");

	/*
	typedef struct {
		 LONG Handle;
		 struct _finddata_t ffile;
		 CHAR  *ff_name;
		 SINT   ff_attrib;
		 CHAR  ff_date[9];
	} FFBLK;

	#endif

	SINT   f_findfirst(CHAR *fname,FFBLK *,SINT attrib);
		*/
				os_errset(OFF);
				fine=f_findFirst(serv,&Fblk,FA_ARCH);
				while (!fine) {ws.maxcam++; fine=f_findNext(&Fblk);}
				f_findClose(&Fblk);

				// Non ci sono pi— files
				if ((fine)&&(DE_coden==0x12)) {fine=0;}
				os_errset(POP);
				if (fine) os_errvedi("ListFile()\n");
				if (ws.maxcam==0) goto FINEC;//	No file

				scrhdl=memoAlloc(M_HEAP,
								   (LONG) ws.maxcam*MAX_X,
								   "listfile()");

				if (scrhdl<0) ehExit("Memoria insufficiente in line");
				pmem=memoPtr(scrhdl);
				//	Copia i nomi dei file in memoria
				os_errset(OFF);
				fine=f_findFirst(serv,&Fblk,FA_ARCH);

				if (fine) {os_errset(POP);goto FINEC;}
				p=pmem; a=0;
				while (!fine) {
					 a++;

					 if (a>ws.maxcam) ehExit("Errore in listafile");
					 strcpy((CHAR *) p,Fblk.ff_name);

					 p+=MAX_X;
					 fine=f_findNext(&Fblk);
				}
				f_findClose(&Fblk);
				// Non ci sono pi— files
				if ((fine)&&(DE_coden==0x12)) {fine=0;}
				os_errset(POP);
				if (fine) os_errvedi("ListFile2()\n");

			//	ORDINA I FILE IN MODO ALFABETICO
				sort(pmem,(SINT) ws.maxcam,MAX_X);

				FINEC:
				mouse_graph(BMS_ax,BMS_ay,Bsys.szMouseCursorName);

				return (SINT *) fine;
				//break;

	case WS_CLOSE : //														  LIBERA LA MEMORIA

				if (scrhdl>-1) memoFree(scrhdl,"Cr3");// Libera la memoria
				scrhdl=-1;
				break;

	case FBEXT:

				if (strlen(str)>3) break;
				strcpy(extcur,str);
				IptMirror=(SINT) info; // Per la copia nell'input
				break;

	case WS_REALSET :
			 PathNow=str;
			 break;

	 }
	return &buf;
#undef MAX_X
#undef MAX_Y

}
Пример #14
0
//														versione Windows
void * listfile(struct OBJ *objCalled,EN_MESSAGE cmd,LONG info,CHAR *str)
{
	#define	 MAX_X 20
	#define	 MAX_Y 30

	static struct WINSCR buf[MAX_Y];
	static struct WS_INFO ws;
	CHAR *ptr;

	LONG a;
	LONG pt;
	struct WS_DISPEXT *DExt;

	static SINT IptMirror;
	static SINT scrhdl=-1;
	//struct ffblk file;
//	FFBLK Fblk;
	EH_DIR sDir;
	SINT fine=0;
	static CHAR *p,*pmem=NULL;
	static CHAR extcur[4];
	//WORD sgm;
	CHAR serv[255];

	//CHAR Bsys.szMouseCursorName[NOMEICONE_SIZE+1]; // Icone corrente del mouse
	//SINT BMS_ax,BMS_ay;

	//-------------------------------------------------

	if (cmd==WS_INF) return &ws;
	switch (cmd) {

	case WS_BUF : //			  			Richiesta buffer

				if (scrhdl==-1) break;
				for (a=0;a<ws.numcam;a++) {
				 pt=a+ws.offset; if (pt>=ws.maxcam) break;
				 buf[(SINT) a].keypt=(CHAR *) (pmem+((SINT) pt*MAX_X));
				}
				break;

	case WS_DISPLAY : //			  			Richiesta buffer

				DExt=(struct WS_DISPEXT *) str;
				ptr=pmem+((SINT) info*MAX_X);
				dispfm_h(DExt->px+2,DExt->py,DExt->col1,DExt->col2,DExt->hdl,ptr);
				
				break;

	case WS_OFF : //			  												Settaggio offset
				ws.offset=info;
				break;

	case WS_KEYPRESS :
				if (key_press(9)||key_press2(_FDX)) strcpy(str,"ESC:->");
				if (key_press2(15)||key_press2(_FSX)) strcpy(str,"ESC:<-");
				//if (key_press(9)) strcpy(str,"ESC:->");
				//if (key_press2(15)) strcpy(str,"ESC:<-");
				break;


	case WS_FINDKEY :
	case WS_FIND : //			  						Ricerca la Chiave selezionata

				if (scrhdl==-1) break;

				strupr(str);
				a=ws.selez+1;

				if (memcmp(str,pmem+((SINT) a*MAX_X),strlen(str))==0)
						{listfile(NULL,WS_OFF,a,"");
						 if (ws.offset>(ws.maxcam-ws.numcam))
								 ws.offset=(ws.maxcam-ws.numcam);
						 if (ws.offset<0) ws.offset=0;
						 listfile(NULL,WS_SEL,a,"");
						 break;}
				{

				for(a=0;a<ws.maxcam;a++)
				{
				 if (memcmp(str,pmem+((SINT) a*MAX_X),strlen(str))<=0)
						{listfile(NULL,WS_OFF,a,"");
						 if (ws.offset>(ws.maxcam-ws.numcam))
								{ws.offset=(ws.maxcam-ws.numcam);}
						 if (ws.offset<0) ws.offset=0;
						 listfile(NULL,WS_SEL,a,"");
						 break;}
				 }
				}
				break;

	case WS_SEL : //			  			Settaggio selez

				ws.selez=info;

				if ((info>-1)&&IptMirror)
					{ipt_write(1,(CHAR *) (pmem+((SINT) info*MAX_X)),0);
					 ipt_vedisolo(1);
					 }

				//sonic(2000,1,1,1,1,6); //ehSleep(30);
				break;

	case WS_PTREC : //			  			Restituisce pt alla chiave selezionata

				buf[0].record=ws.selez;
				buf[0].keypt=(CHAR *) (pmem+((SINT) ws.selez*MAX_X));
				break;


	case WS_REFON : //			  			       Richiesta di refresh schermo

				ws.refre=ON;
				break;

	case WS_REFOFF : //			  											 Schermo rifreshato

				ws.refre=OFF;
				break;

	case WS_OPEN : //														  PREPARA I DATI

				if ((info<4)||(info>MAX_Y))
						{
						ehExit("Errore di assegnazione campi in listfile");
						}

				ws.sizecam=MAX_X;
				ws.numcam=info;// Assegna il numero di campi da visualizzare

	case WS_LOAD :

				if (scrhdl>-1) memoFree(scrhdl,"Cr2");// Libera la memoria

				scrhdl=-1;
				ws.maxcam=0;
				ws.offset=0;
				ws.selez=-1;
				ws.koffset=-1;
				ws.kselez=-1;
				ws.dispext=ON;
				ws.refre=ON;

				//	Conta i file
				strcpy(serv,szFolder); AddBs(serv);
				strcat(serv,"*.");
				strcat(serv,extcur); //strcat(serv,extcur);

				// Cambia il mouse
//				strcpy(Bsys.szMouseCursorName,sys.szMouseCursorName);
//				BMS_ax=MS_ax; BMS_ay=MS_ay;
				mouse_graph(0,0,"CLEX");

		/*
				fine=f_findFirst(serv,&Fblk,FA_ARCH);
				while (!fine) {ws.maxcam++; fine=f_findNext(&Fblk);}
				f_findClose(&Fblk);
				*/
				fileDirOpen(serv,&sDir);
				while (fileDirGet(&sDir)) {ws.maxcam++;}
				fileDirClose(&sDir);
/*
				// Non ci sono pi— files
				if (ws.maxcam)
				{
					if ((DE_coden==ERROR_FILE_NOT_FOUND)||(DE_coden==ERROR_NO_MORE_FILES)) fine=0;
				}
				if (fine) win_infoarg("ListFile() %d\n",DE_coden);
				*/
				if (ws.maxcam==0) goto FINEC;//	No file

				scrhdl=memoAlloc(M_HEAP,(LONG) ws.maxcam*(MAX_X),"listfile()");
				if (scrhdl<0) ehExit("Memoria insufficiente in line");
				pmem=memoPtr(scrhdl,NULL);
				//	Copia i nomi dei file in memoria
				fileDirOpen(serv,&sDir);
				p=pmem; a=0;
				while (fileDirGet(&sDir)) {
//					BYTE *psz;
					a++;
//					if (a>ws.maxcam) ehExit("Errore in listafile");
//					psz=wcsToStr(sDir.sFileInfoW.wcsFileName);
					strcpy((CHAR *) p,sDir.sFileInfo.szFileName);
//					ehFree(psz);
					*p=(BYTE) toupper((SINT) *p);
					p+=MAX_X;
				}
				fileDirClose(&sDir);
/*
				// Non ci sono pi— files
				if (fine)
				{if ((DE_coden==ERROR_FILE_NOT_FOUND)||
						 (DE_coden==ERROR_NO_MORE_FILES)) fine=0;
				}

				if (fine) win_infoarg("ListFile() %d\n",DE_coden);
*/
			//	ORDINA I FILE IN MODO ALFABETICO
				sort(pmem,(SINT) ws.maxcam,MAX_X);

				FINEC:
//				mouse_graph(BMS_ax,BMS_ay,Bsys.szMouseCursorName);
				return (SINT *) fine;
				//break;

	case WS_CLOSE : //														  LIBERA LA MEMORIA

				if (scrhdl>-1) memoFree(scrhdl,"Cr3");// Libera la memoria
				scrhdl=-1;
				break;

	case FBEXT:

				if (strlen(str)>3) break;
				strcpy(extcur,str);
				IptMirror=(SINT) info; // Per la copia nell'input
				break;

	case WS_REALSET :
			 strcpy(szFolder,str);
			 break;
	 }
	return &buf;

#undef MAX_X
#undef MAX_Y
}