Re-implement VFS internals in C++, removing the constraints of the previous implementation.

PiperOrigin-RevId: 649433087
Change-Id: Icaa3e6b7f2ef14f56b04fef2f4360b46d8b5f022
This commit is contained in:
Kyle Bayes
2024-07-04 09:21:18 -07:00
committed by Copybara-Service
parent 118b6810b3
commit 57e6760ec9
19 changed files with 513 additions and 717 deletions
-45
View File
@@ -1407,51 +1407,6 @@ char* mju_strncpy(char *dst, const char *src, int n) {
// assemble full filename from directory and filename, return 0 on success
int mju_makefullname(char* full, size_t nfull, const char* dir, const char* file) {
int dirlen = (!dir) ? 0 : strlen(dir);
int filelen = (!file) ? 0 : strlen(file);
char* filepos = full + dirlen;
// missing filename
if (!filelen) {
return -1;
}
// no directory then just copy filename over
if (!dirlen) {
// make sure full has space
if (filelen >= nfull) {
return -1;
}
strcpy(full, file);
return 0;
}
// make sure full has space
if (dirlen + filelen >= nfull) {
return -1;
}
// dir doesn't end with a slash
if (dir[dirlen - 1] != '\\' && dir[dirlen - 1] != '/') {
// need extra space for forward slash
if ((dirlen + filelen + 1) >= nfull) {
return -1;
}
// add forward slash
*filepos++ = '/';
}
// copy directory and file over
memcpy(full, dir, sizeof(char) * dirlen);
strcpy(filepos, file);
return 0;
}
// sigmoid function over 0<=x<=1 using quintic polynomial
mjtNum mju_sigmoid(mjtNum x) {
// fast return