New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip *nix hidden files #6

Merged
merged 2 commits into from Jul 24, 2018

Conversation

Projects
None yet
2 participants
@AnalogMan151
Contributor

AnalogMan151 commented Jul 22, 2018

Skips files with leading period for *nix and macOS

Skip *nix hidden files
Skips files with leading period for *nix and macOS
@Reisyukaku

This comment has been minimized.

Show comment
Hide comment
@Reisyukaku

Reisyukaku Jul 23, 2018

Owner

Only thing I'm concerned with is it assumes that those files are the last files in the list. Cant find where it says what order fatfs goes in

Owner

Reisyukaku commented Jul 23, 2018

Only thing I'm concerned with is it assumes that those files are the last files in the list. Cant find where it says what order fatfs goes in

@AnalogMan151

This comment has been minimized.

Show comment
Hide comment
@AnalogMan151

AnalogMan151 Jul 23, 2018

Contributor

Ah, good point. It stops the loop as soon as it encounters a file leading with period. Hmmmmm... I'll retract the pull request until I figure it out.

Contributor

AnalogMan151 commented Jul 23, 2018

Ah, good point. It stops the loop as soon as it encounters a file leading with period. Hmmmmm... I'll retract the pull request until I figure it out.

@AnalogMan151

This comment has been minimized.

Show comment
Hide comment
@AnalogMan151

AnalogMan151 Jul 23, 2018

Contributor

Tested this out and it appears to work but I would like your opinion:

    int i = 0; 
    while (fno.fname[0] != 0 && fr == FR_OK) {
        if (fno.fname[0] == '.') {
            f_findnext(&dp, &fno);
            continue;
        }   
        out = (char **)realloc(out, (i+1) * sizeof(char *));
        out[i] = (char *)malloc(FF_LFN_BUF);
        strcpy(out[i], pathb);
        strcat(out[i], fno.fname);
        pathb[pathlen+1] = 0;
        f_findnext(&dp, &fno);
        i++;
    }

Here is the file list in my sys modules folder:

._FS.kip
._loader.kip
._sm.kip
FS.kip
loader.kip
sm.kip

Without the edit my Switch will stall on launching when those files are encountered.

Contributor

AnalogMan151 commented Jul 23, 2018

Tested this out and it appears to work but I would like your opinion:

    int i = 0; 
    while (fno.fname[0] != 0 && fr == FR_OK) {
        if (fno.fname[0] == '.') {
            f_findnext(&dp, &fno);
            continue;
        }   
        out = (char **)realloc(out, (i+1) * sizeof(char *));
        out[i] = (char *)malloc(FF_LFN_BUF);
        strcpy(out[i], pathb);
        strcat(out[i], fno.fname);
        pathb[pathlen+1] = 0;
        f_findnext(&dp, &fno);
        i++;
    }

Here is the file list in my sys modules folder:

._FS.kip
._loader.kip
._sm.kip
FS.kip
loader.kip
sm.kip

Without the edit my Switch will stall on launching when those files are encountered.

@Reisyukaku

This comment has been minimized.

Show comment
Hide comment
@Reisyukaku

Reisyukaku Jul 23, 2018

Owner

if (fno.fname[0] == '.') continue;
should work just fine i'd think

Owner

Reisyukaku commented Jul 23, 2018

if (fno.fname[0] == '.') continue;
should work just fine i'd think

@AnalogMan151

This comment has been minimized.

Show comment
Hide comment
@AnalogMan151

AnalogMan151 Jul 23, 2018

Contributor

I thought that too but that increments i and also does not advance the fno.fname to the next entry (meaning it would just process the same filename over and over). If you did advance to next fno.fname with i incrementing it would leave empty out[] entries when it runs into one of the hidden files. With the while loop i is only incremented when a non-hidden file is found.

Contributor

AnalogMan151 commented Jul 23, 2018

I thought that too but that increments i and also does not advance the fno.fname to the next entry (meaning it would just process the same filename over and over). If you did advance to next fno.fname with i incrementing it would leave empty out[] entries when it runs into one of the hidden files. With the while loop i is only incremented when a non-hidden file is found.

@Reisyukaku

This comment has been minimized.

Show comment
Hide comment
@Reisyukaku

Reisyukaku Jul 23, 2018

Owner

Ah right, in that case maybe this would be cleaner:

int i = 0; 
    while (fno.fname[0] != 0 && fr == FR_OK) {
        if (fno.fname[0] == '.') goto end;  
        out = (char **)realloc(out, (i+1) * sizeof(char *));
        out[i] = (char *)malloc(FF_LFN_BUF);
        strcpy(out[i], pathb);
        strcat(out[i], fno.fname);
        pathb[pathlen+1] = 0;

       end:
        f_findnext(&dp, &fno);
        i++;
    }
Owner

Reisyukaku commented Jul 23, 2018

Ah right, in that case maybe this would be cleaner:

int i = 0; 
    while (fno.fname[0] != 0 && fr == FR_OK) {
        if (fno.fname[0] == '.') goto end;  
        out = (char **)realloc(out, (i+1) * sizeof(char *));
        out[i] = (char *)malloc(FF_LFN_BUF);
        strcpy(out[i], pathb);
        strcat(out[i], fno.fname);
        pathb[pathlen+1] = 0;

       end:
        f_findnext(&dp, &fno);
        i++;
    }
@AnalogMan151

This comment has been minimized.

Show comment
Hide comment
@AnalogMan151

AnalogMan151 Jul 23, 2018

Contributor

That still increments i when a hidden file is processed leaving an empty entry in the array. This perhaps?

int i = 0; 
    while (fno.fname[0] != 0 && fr == FR_OK) {
        if (fno.fname[0] == '.') goto end;  
        out = (char **)realloc(out, (i+1) * sizeof(char *));
        out[i] = (char *)malloc(FF_LFN_BUF);
        strcpy(out[i], pathb);
        strcat(out[i], fno.fname);
        pathb[pathlen+1] = 0;
        i++;
       end:
        f_findnext(&dp, &fno);
    }
Contributor

AnalogMan151 commented Jul 23, 2018

That still increments i when a hidden file is processed leaving an empty entry in the array. This perhaps?

int i = 0; 
    while (fno.fname[0] != 0 && fr == FR_OK) {
        if (fno.fname[0] == '.') goto end;  
        out = (char **)realloc(out, (i+1) * sizeof(char *));
        out[i] = (char *)malloc(FF_LFN_BUF);
        strcpy(out[i], pathb);
        strcat(out[i], fno.fname);
        pathb[pathlen+1] = 0;
        i++;
       end:
        f_findnext(&dp, &fno);
    }
@Reisyukaku

This comment has been minimized.

Show comment
Hide comment
@Reisyukaku

Reisyukaku Jul 23, 2018

Owner

Oh derp. Didnt fully read. Yea, that looks good.

Owner

Reisyukaku commented Jul 23, 2018

Oh derp. Didnt fully read. Yea, that looks good.

Fix skip *nix hidden files
Fixed an issue with previous commit that stopped loading files upon first encounter of hidden file
@AnalogMan151

This comment has been minimized.

Show comment
Hide comment
@AnalogMan151

AnalogMan151 Jul 24, 2018

Contributor

Fix added to pul request.

Contributor

AnalogMan151 commented Jul 24, 2018

Fix added to pul request.

@Reisyukaku Reisyukaku merged commit 11e1cfc into Reisyukaku:master Jul 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment