Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upSkip *nix hidden files #6
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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
|
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 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
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:
Without the edit my Switch will stall on launching when those files are encountered. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
I thought that too but that increments |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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++;
}|
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++;
} |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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);
}|
That still increments 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);
} |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Oh derp. Didnt fully read. Yea, that looks good. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Fix added to pul request. |
AnalogMan151 commentedJul 22, 2018
Skips files with leading period for *nix and macOS