Skip to content

Commit 6b0a3f4

Browse files
Update comments and MAX_PATH to 260
1 parent 85946ee commit 6b0a3f4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libraries/SDFS/src/SDFS.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ class SDFSFileImpl : public FileImpl
274274
} else {
275275
const char *p = _name.get();
276276
const char *slash = strrchr(p, '/');
277+
// For names w/o any path elements, return directly
278+
// If there are slashes, return name after the last slash
279+
// (note that strrchr will return the address of the slash,
280+
// so need to increment to ckip it)
277281
return (slash && slash[1]) ? slash + 1 : p;
278282
}
279283
}
@@ -323,8 +327,9 @@ class SDFSDirImpl : public DirImpl
323327
if (!_valid) {
324328
return FileImplPtr();
325329
}
326-
char tmpName[128];
327-
snprintf(tmpName, sizeof(tmpName), "%s%s%s", _dirPath.get() ? _dirPath.get() : "", _dirPath.get()&&_dirPath.get()[0]?"/":"", _lfn);
330+
// MAX_PATH on FAT32 is potentially 260 bytes per most implementations
331+
char tmpName[260];
332+
snprintf(tmpName, sizeof(tmpName), "%s%s%s", _dirPath.get() ? _dirPath.get() : "", _dirPath.get()&&_dirPath.get()[0]?"/":"", _lfn);
328333
return _fs->open((const char *)tmpName, openMode, accessMode);
329334
}
330335

0 commit comments

Comments
 (0)