Exemple #1
0
void getnextjob(char *name) {
    extern LaosStatus *state;
    extern LaosFileSystem sd;
    char shortname[SHORTFILESIZE], last[SHORTFILESIZE];
    strcpy(last, "");
    sd.getshortname(shortname, name);
    DIR *d;
    struct dirent *p;
    d = opendir("/sd");
    if(d != NULL) {
        while((p = readdir(d)) != NULL) {
            if (strncmp(p->d_name, "longname.sy",11)) { // skip longname.sy*
                if (! strcmp(shortname, last)) {        // if last was shortname
                    sd.getlongname(name, p->d_name);    //    return current
                    closedir(d);
                    return;
                }
                strcpy(last, p->d_name);
            }
        } // while
        closedir(d);
    } else {
        state->setErrorMessage("Getfilename: Could not open directory!\n\r");
    }
    sd.getlongname(name, last);     // if last file was match, return the last
                                    // if filename not found, return last
                                    // if no file in directory, return ""
}
Exemple #2
0
void getprevjob(char *name) {
    extern LaosStatus *state;
    extern LaosFileSystem sd;
    char shortname[SHORTFILESIZE], last[SHORTFILESIZE];
    strcpy(last, "");
    sd.getshortname(shortname, name);
    DIR *d;
    struct dirent *p;
    d = opendir("/sd");
    if(d != NULL) {
        while((p = readdir(d)) != NULL) {
            if (strncmp(p->d_name, "longname.sy",11)) { // skip longname.sy*
                if (! strcmp(shortname, p->d_name)) {   // shortname = current entry
                    if (strcmp(last, "")) {
                        sd.getlongname(name, last);     // return entry before
                    } else {
                        sd.getlongname(name, p->d_name);    // last="", so current = first
                    }
                    closedir(d);
                    return;
                }
                strcpy(last, p->d_name);
            }
        } // while
        closedir(d);
    } else {
        state->setErrorMessage("Getfilename: Could not open directory!\n\r");
    }
    sd.getlongname(name, last); // name not found (return last) 
                                // or no file found (return "") 
}