mirror of
https://github.com/wiiu-env/ContentRedirectionModule.git
synced 2025-02-22 22:07:10 +01:00
Use shared_ptr/unique_ptr instead of raw ptr
This commit is contained in:
parent
79755b6bb9
commit
8043922311
@ -14,10 +14,9 @@ DECL_FUNCTION(FSStatus, FSOpenDir, FSClient *client, FSCmdBlock *block, char *pa
|
||||
client,
|
||||
errorMask,
|
||||
[c = client, b = block, h = handle, p = path](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
auto res = real_FSOpenDir(c, b, p, h, realErrorMask);
|
||||
return res;
|
||||
return real_FSOpenDir(c, b, p, h, realErrorMask);
|
||||
},
|
||||
[f = getFullPathForClient(client, path), h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[f = getFullPathForClient(client, path), h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSOpenDirWrapper(f.c_str(), h);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -35,7 +34,7 @@ DECL_FUNCTION(FSStatus, FSOpenDirAsync, FSClient *client, FSCmdBlock *block, cha
|
||||
[c = client, b = block, h = handle, p = path, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSOpenDirAsync(c, b, p, h, realErrorMask, a);
|
||||
},
|
||||
[f = getFullPathForClient(client, path), h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[f = getFullPathForClient(client, path), h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSOpenDirWrapper(f.c_str(), h);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -52,7 +51,7 @@ DECL_FUNCTION(FSStatus, FSReadDir, FSClient *client, FSCmdBlock *block, FSDirect
|
||||
[c = client, b = block, h = handle, e = entry](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSReadDir(c, b, h, e, realErrorMask);
|
||||
},
|
||||
[h = handle, e = entry](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle, e = entry](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSReadDirWrapper(h, e);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -69,7 +68,7 @@ DECL_FUNCTION(FSStatus, FSReadDirAsync, FSClient *client, FSCmdBlock *block, FSD
|
||||
[c = client, b = block, h = handle, e = entry, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSReadDirAsync(c, b, h, e, realErrorMask, a);
|
||||
},
|
||||
[h = handle, e = entry](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle, e = entry](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSReadDirWrapper(h, e);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -86,10 +85,10 @@ DECL_FUNCTION(FSStatus, FSCloseDir, FSClient *client, FSCmdBlock *block, FSDirec
|
||||
[c = client, b = block, h = handle](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSCloseDir(c, b, h, realErrorMask);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSCloseDirWrapper(h);
|
||||
},
|
||||
[h = handle, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__](IFSWrapper *layer, FSStatus res) -> FSStatus {
|
||||
[h = handle, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__](std::unique_ptr<IFSWrapper> &layer, FSStatus res) -> FSStatus {
|
||||
if (layer->isValidDirHandle(h)) {
|
||||
layer->deleteDirHandle(h);
|
||||
} else {
|
||||
@ -111,10 +110,10 @@ DECL_FUNCTION(FSStatus, FSCloseDirAsync, FSClient *client, FSCmdBlock *block, FS
|
||||
[c = client, b = block, h = handle, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSCloseDirAsync(c, b, h, realErrorMask, a);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSCloseDirWrapper(h);
|
||||
},
|
||||
[c = client, b = block, h = handle, a = asyncData, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__](IFSWrapper *layer, FSStatus res) -> FSStatus {
|
||||
[c = client, b = block, h = handle, a = asyncData, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__](std::unique_ptr<IFSWrapper> &layer, FSStatus res) -> FSStatus {
|
||||
if (layer->isValidDirHandle(h)) {
|
||||
layer->deleteDirHandle(h);
|
||||
} else {
|
||||
@ -136,7 +135,7 @@ DECL_FUNCTION(FSStatus, FSRewindDir, FSClient *client, FSCmdBlock *block, FSDire
|
||||
[c = client, b = block, h = handle](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSRewindDir(c, b, h, realErrorMask);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSRewindDirWrapper(h);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -153,7 +152,7 @@ DECL_FUNCTION(FSStatus, FSRewindDirAsync, FSClient *client, FSCmdBlock *block, F
|
||||
[c = client, b = block, h = handle, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSRewindDirAsync(c, b, h, realErrorMask, a);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSRewindDirWrapper(h);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -170,7 +169,7 @@ DECL_FUNCTION(FSStatus, FSMakeDir, FSClient *client, FSCmdBlock *block, char *pa
|
||||
[c = client, b = block, p = path](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSMakeDir(c, b, p, realErrorMask);
|
||||
},
|
||||
[f = getFullPathForClient(client, path)](IFSWrapper *layer) -> FSStatus {
|
||||
[f = getFullPathForClient(client, path)](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSMakeDirWrapper(f.c_str());
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -187,7 +186,7 @@ DECL_FUNCTION(FSStatus, FSMakeDirAsync, FSClient *client, FSCmdBlock *block, cha
|
||||
[c = client, b = block, p = path, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSMakeDirAsync(c, b, p, realErrorMask, a);
|
||||
},
|
||||
[f = getFullPathForClient(client, path)](IFSWrapper *layer) -> FSStatus {
|
||||
[f = getFullPathForClient(client, path)](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSMakeDirWrapper(f.c_str());
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
|
@ -15,7 +15,7 @@ DECL_FUNCTION(FSStatus, FSOpenFile, FSClient *client, FSCmdBlock *block, char *p
|
||||
[c = client, b = block, p = path, m = mode, h = handle](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSOpenFile(c, b, p, m, h, realErrorMask);
|
||||
},
|
||||
[f = getFullPathForClient(client, path), m = mode, h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[f = getFullPathForClient(client, path), m = mode, h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSOpenFileWrapper(f.c_str(), m, h);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -32,7 +32,7 @@ DECL_FUNCTION(FSStatus, FSOpenFileAsync, FSClient *client, FSCmdBlock *block, ch
|
||||
[c = client, b = block, p = path, m = mode, h = handle, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSOpenFileAsync(c, b, p, m, h, realErrorMask, a);
|
||||
},
|
||||
[p = getFullPathForClient(client, path), m = mode, h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[p = getFullPathForClient(client, path), m = mode, h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSOpenFileWrapper(p.c_str(), m, h);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -49,10 +49,10 @@ DECL_FUNCTION(FSStatus, FSCloseFile, FSClient *client, FSCmdBlock *block, FSFile
|
||||
[c = client, b = block, h = handle](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSCloseFile(c, b, h, realErrorMask);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSCloseFileWrapper(h);
|
||||
},
|
||||
[h = handle, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__](IFSWrapper *layer, FSStatus res) -> FSStatus {
|
||||
[h = handle, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__](std::unique_ptr<IFSWrapper> &layer, FSStatus res) -> FSStatus {
|
||||
if (layer->isValidFileHandle(h)) {
|
||||
layer->deleteFileHandle(h);
|
||||
} else {
|
||||
@ -74,10 +74,10 @@ DECL_FUNCTION(FSStatus, FSCloseFileAsync, FSClient *client, FSCmdBlock *block, F
|
||||
[c = client, b = block, h = handle, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSCloseFileAsync(c, b, h, realErrorMask, a);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSCloseFileWrapper(h);
|
||||
},
|
||||
[c = client, b = block, h = handle, a = asyncData, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__](IFSWrapper *layer, FSStatus res) -> FSStatus {
|
||||
[c = client, b = block, h = handle, a = asyncData, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__](std::unique_ptr<IFSWrapper> &layer, FSStatus res) -> FSStatus {
|
||||
if (layer->isValidFileHandle(h)) {
|
||||
layer->deleteFileHandle(h);
|
||||
} else {
|
||||
@ -99,7 +99,7 @@ DECL_FUNCTION(FSStatus, FSGetStat, FSClient *client, FSCmdBlock *block, char *pa
|
||||
[c = client, b = block, p = path, s = stats](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSGetStat(c, b, p, s, realErrorMask);
|
||||
},
|
||||
[p = getFullPathForClient(client, path), s = stats](IFSWrapper *layer) -> FSStatus {
|
||||
[p = getFullPathForClient(client, path), s = stats](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSGetStatWrapper(p.c_str(), s);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -116,7 +116,7 @@ DECL_FUNCTION(FSStatus, FSGetStatAsync, FSClient *client, FSCmdBlock *block, cha
|
||||
[c = client, b = block, p = path, s = stats, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSGetStatAsync(c, b, p, s, realErrorMask, a);
|
||||
},
|
||||
[p = getFullPathForClient(client, path), s = stats](IFSWrapper *layer) -> FSStatus {
|
||||
[p = getFullPathForClient(client, path), s = stats](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSGetStatWrapper(p.c_str(), s);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -133,7 +133,7 @@ DECL_FUNCTION(FSStatus, FSGetStatFile, FSClient *client, FSCmdBlock *block, FSFi
|
||||
[c = client, b = block, h = handle, s = stats](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSGetStatFile(c, b, h, s, realErrorMask);
|
||||
},
|
||||
[h = handle, s = stats](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle, s = stats](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSGetStatFileWrapper(h, s);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -150,7 +150,7 @@ DECL_FUNCTION(FSStatus, FSGetStatFileAsync, FSClient *client, FSCmdBlock *block,
|
||||
[c = client, b = block, h = handle, s = stats, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSGetStatFileAsync(c, b, h, s, realErrorMask, a);
|
||||
},
|
||||
[h = handle, s = stats](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle, s = stats](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSGetStatFileWrapper(h, s);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -167,7 +167,7 @@ DECL_FUNCTION(FSStatus, FSReadFile, FSClient *client, FSCmdBlock *block, void *b
|
||||
[c = client, b = block, h = handle, s = size, co = count, bu = buffer, u = unk1](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSReadFile(c, b, bu, s, co, h, u, realErrorMask);
|
||||
},
|
||||
[b = buffer, s = size, c = count, h = handle, u = unk1](IFSWrapper *layer) -> FSStatus {
|
||||
[b = buffer, s = size, c = count, h = handle, u = unk1](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSReadFileWrapper(b, s, c, h, u);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -185,7 +185,7 @@ DECL_FUNCTION(FSStatus, FSReadFileAsync, FSClient *client, FSCmdBlock *block, vo
|
||||
[c = client, b = block, h = handle, s = size, co = count, bu = buffer, u = unk1, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSReadFileAsync(c, b, bu, s, co, h, u, realErrorMask, a);
|
||||
},
|
||||
[b = buffer, s = size, c = count, h = handle, u = unk1](IFSWrapper *layer) -> FSStatus {
|
||||
[b = buffer, s = size, c = count, h = handle, u = unk1](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSReadFileWrapper(b, s, c, h, u);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -202,7 +202,7 @@ DECL_FUNCTION(FSStatus, FSReadFileWithPos, FSClient *client, FSCmdBlock *block,
|
||||
[c = client, b = block, h = handle, s = size, co = count, p = pos, bu = buffer, u = unk1](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSReadFileWithPos(c, b, bu, s, co, p, h, u, realErrorMask);
|
||||
},
|
||||
[b = buffer, s = size, c = count, p = pos, h = handle, u = unk1](IFSWrapper *layer) -> FSStatus {
|
||||
[b = buffer, s = size, c = count, p = pos, h = handle, u = unk1](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSReadFileWithPosWrapper(b, s, c, p, h, u);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -220,7 +220,7 @@ DECL_FUNCTION(FSStatus, FSReadFileWithPosAsync, FSClient *client, FSCmdBlock *bl
|
||||
[c = client, b = block, h = handle, s = size, co = count, p = pos, bu = buffer, u = unk1, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSReadFileWithPosAsync(c, b, bu, s, co, p, h, u, realErrorMask, a);
|
||||
},
|
||||
[b = buffer, s = size, c = count, p = pos, h = handle, u = unk1](IFSWrapper *layer) -> FSStatus {
|
||||
[b = buffer, s = size, c = count, p = pos, h = handle, u = unk1](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSReadFileWithPosWrapper(b, s, c, p, h, u);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -237,7 +237,7 @@ DECL_FUNCTION(FSStatus, FSSetPosFile, FSClient *client, FSCmdBlock *block, FSFil
|
||||
[c = client, b = block, h = handle, p = pos](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSSetPosFile(c, b, h, p, realErrorMask);
|
||||
},
|
||||
[h = handle, p = pos](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle, p = pos](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSSetPosFileWrapper(h, p);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -254,7 +254,7 @@ DECL_FUNCTION(FSStatus, FSSetPosFileAsync, FSClient *client, FSCmdBlock *block,
|
||||
[c = client, b = block, h = handle, p = pos, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSSetPosFileAsync(c, b, h, p, realErrorMask, a);
|
||||
},
|
||||
[h = handle, p = pos](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle, p = pos](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSSetPosFileWrapper(h, p);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -271,7 +271,7 @@ DECL_FUNCTION(FSStatus, FSGetPosFile, FSClient *client, FSCmdBlock *block, FSFil
|
||||
[c = client, b = block, h = handle, p = pos](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSGetPosFile(c, b, h, p, realErrorMask);
|
||||
},
|
||||
[h = handle, p = pos](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle, p = pos](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSGetPosFileWrapper(h, p);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -288,7 +288,7 @@ DECL_FUNCTION(FSStatus, FSGetPosFileAsync, FSClient *client, FSCmdBlock *block,
|
||||
[c = client, b = block, h = handle, p = pos, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSGetPosFileAsync(c, b, h, p, realErrorMask, a);
|
||||
},
|
||||
[h = handle, p = pos](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle, p = pos](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSGetPosFileWrapper(h, p);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -305,7 +305,7 @@ DECL_FUNCTION(FSStatus, FSIsEof, FSClient *client, FSCmdBlock *block, FSFileHand
|
||||
[c = client, b = block, h = handle](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSIsEof(c, b, h, realErrorMask);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSIsEofWrapper(h);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -322,7 +322,7 @@ DECL_FUNCTION(FSStatus, FSIsEofAsync, FSClient *client, FSCmdBlock *block, FSFil
|
||||
[c = client, b = block, h = handle, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSIsEofAsync(c, b, h, realErrorMask, a);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSIsEofWrapper(h);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -339,7 +339,7 @@ DECL_FUNCTION(FSStatus, FSWriteFile, FSClient *client, FSCmdBlock *block, uint8_
|
||||
[c = client, b = block, bu = buffer, s = size, co = count, h = handle, u = unk1](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSWriteFile(c, b, bu, s, co, h, u, realErrorMask);
|
||||
},
|
||||
[b = buffer, s = size, c = count, h = handle, u = unk1](IFSWrapper *layer) -> FSStatus {
|
||||
[b = buffer, s = size, c = count, h = handle, u = unk1](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSWriteFileWrapper(b, s, c, h, u);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -357,7 +357,7 @@ DECL_FUNCTION(FSStatus, FSWriteFileAsync, FSClient *client, FSCmdBlock *block, u
|
||||
[c = client, b = block, bu = buffer, s = size, co = count, h = handle, u = unk1, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSWriteFileAsync(c, b, bu, s, co, h, u, realErrorMask, a);
|
||||
},
|
||||
[b = buffer, s = size, c = count, h = handle, u = unk1](IFSWrapper *layer) -> FSStatus {
|
||||
[b = buffer, s = size, c = count, h = handle, u = unk1](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSWriteFileWrapper(b, s, c, h, u);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -374,7 +374,7 @@ DECL_FUNCTION(FSStatus, FSTruncateFile, FSClient *client, FSCmdBlock *block, FSF
|
||||
[c = client, b = block, h = handle](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSTruncateFile(c, b, h, realErrorMask);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSTruncateFileWrapper(h);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -391,7 +391,7 @@ DECL_FUNCTION(FSStatus, FSTruncateFileAsync, FSClient *client, FSCmdBlock *block
|
||||
[c = client, b = block, h = handle, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSTruncateFileAsync(c, b, h, realErrorMask, a);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSTruncateFileWrapper(h);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -408,7 +408,7 @@ DECL_FUNCTION(FSStatus, FSRemove, FSClient *client, FSCmdBlock *block, char *pat
|
||||
[c = client, b = block, p = path](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSRemove(c, b, p, realErrorMask);
|
||||
},
|
||||
[p = getFullPathForClient(client, path)](IFSWrapper *layer) -> FSStatus {
|
||||
[p = getFullPathForClient(client, path)](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSRemoveWrapper(p.c_str());
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -425,7 +425,7 @@ DECL_FUNCTION(FSStatus, FSRemoveAsync, FSClient *client, FSCmdBlock *block, char
|
||||
[c = client, b = block, p = path, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSRemoveAsync(c, b, p, realErrorMask, a);
|
||||
},
|
||||
[p = getFullPathForClient(client, path)](IFSWrapper *layer) -> FSStatus {
|
||||
[p = getFullPathForClient(client, path)](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSRemoveWrapper(p.c_str());
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -442,7 +442,7 @@ DECL_FUNCTION(FSStatus, FSRename, FSClient *client, FSCmdBlock *block, char *old
|
||||
[c = client, b = block, oP = oldPath, nP = newPath](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSRename(c, b, oP, nP, realErrorMask);
|
||||
},
|
||||
[oP = getFullPathForClient(client, oldPath), nP = getFullPathForClient(client, newPath)](IFSWrapper *layer) -> FSStatus {
|
||||
[oP = getFullPathForClient(client, oldPath), nP = getFullPathForClient(client, newPath)](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSRenameWrapper(oP.c_str(), nP.c_str());
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -465,7 +465,7 @@ DECL_FUNCTION(FSStatus, FSRenameAsync,
|
||||
[c = client, b = block, oP = oldPath, nP = newPath, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSRenameAsync(c, b, oP, nP, realErrorMask, a);
|
||||
},
|
||||
[oP = getFullPathForClient(client, oldPath), nP = getFullPathForClient(client, newPath)](IFSWrapper *layer) -> FSStatus {
|
||||
[oP = getFullPathForClient(client, oldPath), nP = getFullPathForClient(client, newPath)](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSRenameWrapper(oP.c_str(), nP.c_str());
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -482,7 +482,7 @@ DECL_FUNCTION(FSStatus, FSFlushFile, FSClient *client, FSCmdBlock *block, [[mayb
|
||||
[c = client, b = block, h = handle](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSFlushFile(c, b, h, realErrorMask);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSFlushFileWrapper(h);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -499,7 +499,7 @@ DECL_FUNCTION(FSStatus, FSFlushFileAsync, FSClient *client, FSCmdBlock *block, [
|
||||
[c = client, b = block, h = handle, a = asyncData](FSErrorFlag realErrorMask) -> FSStatus {
|
||||
return real_FSFlushFileAsync(c, b, h, realErrorMask, a);
|
||||
},
|
||||
[h = handle](IFSWrapper *layer) -> FSStatus {
|
||||
[h = handle](std::unique_ptr<IFSWrapper> &layer) -> FSStatus {
|
||||
return layer->FSFlushFileWrapper(h);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "FileUtils.h"
|
||||
#include "utils/StringTools.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
#include <algorithm>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
@ -23,15 +24,15 @@ FSStatus FSWrapper::FSOpenDirWrapper(const char *path, FSDirectoryHandle *handle
|
||||
|
||||
FSStatus result = FS_STATUS_OK;
|
||||
|
||||
auto *dirHandle = getNewDirHandle();
|
||||
if (dirHandle != nullptr) {
|
||||
auto dirHandle = getNewDirHandle();
|
||||
if (dirHandle) {
|
||||
DIR *dir;
|
||||
auto newPath = GetNewPath(path);
|
||||
|
||||
if ((dir = opendir(newPath.c_str()))) {
|
||||
|
||||
dirHandle->dir = dir;
|
||||
dirHandle->handle = (((uint32_t) dirHandle) & 0x0FFFFFFF) | 0x30000000;
|
||||
dirHandle->handle = (((uint32_t) dirHandle.get()) & 0x0FFFFFFF) | 0x30000000;
|
||||
*handle = dirHandle->handle;
|
||||
|
||||
dirHandle->path[0] = '\0';
|
||||
@ -42,7 +43,6 @@ FSStatus FSWrapper::FSOpenDirWrapper(const char *path, FSDirectoryHandle *handle
|
||||
OSMemoryBarrier();
|
||||
}
|
||||
} else {
|
||||
delete dirHandle;
|
||||
result = FS_STATUS_NOT_FOUND;
|
||||
}
|
||||
} else {
|
||||
@ -56,7 +56,7 @@ FSStatus FSWrapper::FSReadDirWrapper(FSDirectoryHandle handle, FSDirectoryEntry
|
||||
if (!isValidDirHandle(handle)) {
|
||||
return FS_STATUS_FORCE_PARENT_LAYER;
|
||||
}
|
||||
auto *dirHandle = getDirFromHandle(handle);
|
||||
auto dirHandle = getDirFromHandle(handle);
|
||||
|
||||
DIR *dir = dirHandle->dir;
|
||||
|
||||
@ -104,7 +104,7 @@ FSStatus FSWrapper::FSCloseDirWrapper(FSDirectoryHandle handle) {
|
||||
if (!isValidDirHandle(handle)) {
|
||||
return FS_STATUS_FORCE_PARENT_LAYER;
|
||||
}
|
||||
auto *dirHandle = getDirFromHandle(handle);
|
||||
auto dirHandle = getDirFromHandle(handle);
|
||||
|
||||
DIR *dir = dirHandle->dir;
|
||||
|
||||
@ -123,7 +123,7 @@ FSStatus FSWrapper::FSRewindDirWrapper(FSDirectoryHandle handle) {
|
||||
if (!isValidDirHandle(handle)) {
|
||||
return FS_STATUS_FORCE_PARENT_LAYER;
|
||||
}
|
||||
auto *dirHandle = getDirFromHandle(handle);
|
||||
auto dirHandle = getDirFromHandle(handle);
|
||||
|
||||
DIR *dir = dirHandle->dir;
|
||||
|
||||
@ -196,12 +196,12 @@ FSStatus FSWrapper::FSOpenFileWrapper(const char *path, const char *mode, FSFile
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Open %s (as %s) mode %s,", getName().c_str(), path, newPath.c_str(), mode);
|
||||
int32_t fd = open(newPath.c_str(), _mode);
|
||||
if (fd >= 0) {
|
||||
auto *fileHandle = getNewFileHandle();
|
||||
auto fileHandle = getNewFileHandle();
|
||||
if (fileHandle) {
|
||||
std::lock_guard<std::mutex> lock(openFilesMutex);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Opened %s (as %s) mode %s, fd %d (%08X)", getName().c_str(), path, newPath.c_str(), mode, fd, handle);
|
||||
|
||||
fileHandle->handle = (((uint32_t) fileHandle) & 0x0FFFFFFF) | 0x30000000;
|
||||
fileHandle->handle = (((uint32_t) fileHandle.get()) & 0x0FFFFFFF) | 0x30000000;
|
||||
*handle = fileHandle->handle;
|
||||
fileHandle->fd = fd;
|
||||
|
||||
@ -226,7 +226,7 @@ FSStatus FSWrapper::FSCloseFileWrapper(FSFileHandle handle) {
|
||||
return FS_STATUS_FORCE_PARENT_LAYER;
|
||||
}
|
||||
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
|
||||
int real_fd = fileHandle->fd;
|
||||
|
||||
@ -301,7 +301,7 @@ FSStatus FSWrapper::FSGetStatFileWrapper(FSFileHandle handle, FSStat *stats) {
|
||||
if (!isValidFileHandle(handle)) {
|
||||
return FS_STATUS_FORCE_PARENT_LAYER;
|
||||
}
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
|
||||
int real_fd = fileHandle->fd;
|
||||
|
||||
@ -339,8 +339,8 @@ FSStatus FSWrapper::FSReadFileWrapper(void *buffer, uint32_t size, uint32_t coun
|
||||
return FS_STATUS_FATAL_ERROR;
|
||||
}
|
||||
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
int real_fd = fileHandle->fd;
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
int real_fd = fileHandle->fd;
|
||||
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Read %u bytes of fd %08X (FSFileHandle %08X) to buffer %08X", getName().c_str(), size * count, real_fd, handle, buffer);
|
||||
int32_t read = readIntoBuffer(real_fd, buffer, size, count);
|
||||
@ -375,7 +375,7 @@ FSStatus FSWrapper::FSSetPosFileWrapper(FSFileHandle handle, uint32_t pos) {
|
||||
if (!isValidFileHandle(handle)) {
|
||||
return FS_STATUS_FORCE_PARENT_LAYER;
|
||||
}
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
|
||||
FSStatus result = FS_STATUS_OK;
|
||||
|
||||
@ -396,7 +396,7 @@ FSStatus FSWrapper::FSGetPosFileWrapper(FSFileHandle handle, uint32_t *pos) {
|
||||
if (!isValidFileHandle(handle)) {
|
||||
return FS_STATUS_FORCE_PARENT_LAYER;
|
||||
}
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
|
||||
FSStatus result = FS_STATUS_OK;
|
||||
|
||||
@ -417,7 +417,7 @@ FSStatus FSWrapper::FSIsEofWrapper(FSFileHandle handle) {
|
||||
if (!isValidFileHandle(handle)) {
|
||||
return FS_STATUS_FORCE_PARENT_LAYER;
|
||||
}
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
|
||||
FSStatus result;
|
||||
|
||||
@ -453,7 +453,7 @@ FSStatus FSWrapper::FSTruncateFileWrapper(FSFileHandle handle) {
|
||||
return FS_STATUS_ACCESS_ERROR;
|
||||
}
|
||||
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
|
||||
FSStatus result = FS_STATUS_OK;
|
||||
|
||||
@ -483,7 +483,7 @@ FSStatus FSWrapper::FSWriteFileWrapper(uint8_t *buffer, uint32_t size, uint32_t
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Tried to write to fd %d (handle %08X) but layer is not writeable", getName().c_str(), getFileFromHandle(handle)->fd, handle);
|
||||
return FS_STATUS_ACCESS_ERROR;
|
||||
}
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
|
||||
FSStatus result;
|
||||
|
||||
@ -572,8 +572,8 @@ FSStatus FSWrapper::FSFlushFileWrapper(FSFileHandle handle) {
|
||||
return FS_STATUS_ACCESS_ERROR;
|
||||
}
|
||||
|
||||
auto *fileHandle = getFileFromHandle(handle);
|
||||
int real_fd = fileHandle->fd;
|
||||
auto fileHandle = getFileFromHandle(handle);
|
||||
int real_fd = fileHandle->fd;
|
||||
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] fsync fd %08X (FSFileHandle %08X)", real_fd, handle);
|
||||
FSStatus result = FS_STATUS_OK;
|
||||
@ -608,7 +608,7 @@ std::string FSWrapper::GetNewPath(const std::string_view &path) {
|
||||
auto subStr = path.substr(this->pPathToReplace.length());
|
||||
auto res = string_format("%s%.*s", this->pReplacePathWith.c_str(), int(subStr.length()), subStr.data());
|
||||
|
||||
std::replace(res.begin(), res.end(), '/', '/');
|
||||
std::replace(res.begin(), res.end(), '\\', '/');
|
||||
|
||||
uint32_t length = res.size();
|
||||
|
||||
@ -627,23 +627,23 @@ std::string FSWrapper::GetNewPath(const std::string_view &path) {
|
||||
|
||||
bool FSWrapper::isValidFileHandle(FSFileHandle handle) {
|
||||
std::lock_guard<std::mutex> lock(openFilesMutex);
|
||||
return std::ranges::any_of(openFiles, [handle](FileInfo *val) { return val->handle == handle; });
|
||||
return std::ranges::any_of(openFiles, [handle](auto &cur) { return cur->handle == handle; });
|
||||
}
|
||||
|
||||
bool FSWrapper::isValidDirHandle(FSDirectoryHandle handle) {
|
||||
std::lock_guard<std::mutex> lock(openDirsMutex);
|
||||
return std::ranges::any_of(openDirs, [handle](DirInfo *val) { return val->handle == handle; });
|
||||
return std::ranges::any_of(openDirs, [handle](auto &cur) { return cur->handle == handle; });
|
||||
}
|
||||
|
||||
FileInfo *FSWrapper::getNewFileHandle() {
|
||||
return new (std::nothrow) FileInfo;
|
||||
std::shared_ptr<FileInfo> FSWrapper::getNewFileHandle() {
|
||||
return make_shared_nothrow<FileInfo>();
|
||||
}
|
||||
|
||||
DirInfo *FSWrapper::getNewDirHandle() {
|
||||
return new (std::nothrow) DirInfo;
|
||||
std::shared_ptr<DirInfo> FSWrapper::getNewDirHandle() {
|
||||
return make_shared_nothrow<DirInfo>();
|
||||
}
|
||||
|
||||
FileInfo *FSWrapper::getFileFromHandle(FSFileHandle handle) {
|
||||
std::shared_ptr<FileInfo> FSWrapper::getFileFromHandle(FSFileHandle handle) {
|
||||
std::lock_guard<std::mutex> lock(openFilesMutex);
|
||||
for (auto &file : openFiles) {
|
||||
if (file->handle == handle) {
|
||||
@ -655,7 +655,7 @@ FileInfo *FSWrapper::getFileFromHandle(FSFileHandle handle) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DirInfo *FSWrapper::getDirFromHandle(FSDirectoryHandle handle) {
|
||||
std::shared_ptr<DirInfo> FSWrapper::getDirFromHandle(FSDirectoryHandle handle) {
|
||||
std::lock_guard<std::mutex> lock(openDirsMutex);
|
||||
for (auto &dir : openDirs) {
|
||||
if (dir->handle == handle) {
|
||||
@ -668,43 +668,13 @@ DirInfo *FSWrapper::getDirFromHandle(FSDirectoryHandle handle) {
|
||||
}
|
||||
|
||||
void FSWrapper::deleteDirHandle(FSDirectoryHandle handle) {
|
||||
std::lock_guard<std::mutex> lock(openDirsMutex);
|
||||
bool found = false;
|
||||
int count = 0;
|
||||
DirInfo *info;
|
||||
for (auto &val : openDirs) {
|
||||
if ((FSDirectoryHandle) val->handle == handle) {
|
||||
found = true;
|
||||
info = val;
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (found) {
|
||||
openDirs.erase(openDirs.begin() + count);
|
||||
delete info;
|
||||
} else {
|
||||
if (!remove_locked_first_if(openDirsMutex, openDirs, [handle](auto &cur) { return (FSFileHandle) cur->handle == handle; })) {
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] Delete failed because the handle %08X was not found", getName().c_str(), handle);
|
||||
}
|
||||
}
|
||||
|
||||
void FSWrapper::deleteFileHandle(FSFileHandle handle) {
|
||||
std::lock_guard<std::mutex> lock(openFilesMutex);
|
||||
bool found = false;
|
||||
auto count = 0;
|
||||
FileInfo *info;
|
||||
for (auto &val : openFiles) {
|
||||
if ((FSFileHandle) val->handle == handle) {
|
||||
found = true;
|
||||
info = val;
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (found) {
|
||||
openFiles.erase(openFiles.begin() + count);
|
||||
delete info;
|
||||
} else {
|
||||
if (!remove_locked_first_if(openFilesMutex, openFiles, [handle](auto &cur) { return (FSFileHandle) cur->handle == handle; })) {
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] Delete failed because the handle %08X was not found", getName().c_str(), handle);
|
||||
}
|
||||
}
|
||||
|
@ -22,18 +22,12 @@ public:
|
||||
std::replace(pReplacePathWith.begin(), pReplacePathWith.end(), '\\', '/');
|
||||
}
|
||||
~FSWrapper() override {
|
||||
if (!openFiles.empty()) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Clean leaked fileInfos");
|
||||
for (auto &file : openFiles) {
|
||||
delete file;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lockFiles(openFilesMutex);
|
||||
openFiles.clear();
|
||||
}
|
||||
if (!openDirs.empty()) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Clean leaked dirInfos");
|
||||
for (auto &dir : openDirs) {
|
||||
delete dir;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lockDirs(openDirsMutex);
|
||||
openDirs.clear();
|
||||
}
|
||||
}
|
||||
@ -108,8 +102,8 @@ protected:
|
||||
|
||||
std::string GetNewPath(const std::string_view &path);
|
||||
|
||||
DirInfo *getDirFromHandle(FSDirectoryHandle handle);
|
||||
FileInfo *getFileFromHandle(FSFileHandle handle);
|
||||
std::shared_ptr<DirInfo> getDirFromHandle(FSDirectoryHandle handle);
|
||||
std::shared_ptr<FileInfo> getFileFromHandle(FSFileHandle handle);
|
||||
|
||||
bool isValidDirHandle(FSDirectoryHandle handle) override;
|
||||
bool isValidFileHandle(FSFileHandle handle) override;
|
||||
@ -119,8 +113,8 @@ protected:
|
||||
|
||||
virtual bool CheckFileShouldBeIgnored(std::string &path);
|
||||
|
||||
virtual FileInfo *getNewFileHandle();
|
||||
virtual DirInfo *getNewDirHandle();
|
||||
virtual std::shared_ptr<FileInfo> getNewFileHandle();
|
||||
virtual std::shared_ptr<DirInfo> getNewDirHandle();
|
||||
|
||||
virtual bool SkipDeletedFilesInReadDir();
|
||||
|
||||
@ -134,6 +128,6 @@ private:
|
||||
bool pIsWriteable = false;
|
||||
std::mutex openFilesMutex;
|
||||
std::mutex openDirsMutex;
|
||||
std::vector<FileInfo *> openFiles;
|
||||
std::vector<DirInfo *> openDirs;
|
||||
std::vector<std::shared_ptr<FileInfo>> openFiles;
|
||||
std::vector<std::shared_ptr<DirInfo>> openDirs;
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "FSWrapperMergeDirsWithParent.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/filesystem.h>
|
||||
@ -13,7 +14,7 @@ FSStatus FSWrapperMergeDirsWithParent::FSOpenDirWrapper(const char *path,
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] No valid dir handle %08X", getName().c_str(), *handle);
|
||||
return FS_STATUS_FATAL_ERROR;
|
||||
}
|
||||
auto *dirHandle = getDirExFromHandle(*handle);
|
||||
auto dirHandle = getDirExFromHandle(*handle);
|
||||
if (dirHandle != nullptr) {
|
||||
dirHandle->readResultCapacity = 0;
|
||||
dirHandle->readResultNumberOfEntries = 0;
|
||||
@ -21,9 +22,9 @@ FSStatus FSWrapperMergeDirsWithParent::FSOpenDirWrapper(const char *path,
|
||||
|
||||
if (pFSClient && pCmdBlock) {
|
||||
FSDirectoryHandle realHandle = 0;
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Call real_FSOpenDir for %s with error_flag %08X", getName().c_str(), path, (uint32_t) this);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Call real_FSOpenDir for %s with error_flag %08X", getName().c_str(), path, this->getHandle());
|
||||
// Call FSOpen with "this" as errorFlag call FSOpen for "parent" layers only.
|
||||
if (FSOpenDir(pFSClient, pCmdBlock, path, &realHandle, (FSErrorFlag) (uint32_t) this) == FS_STATUS_OK) {
|
||||
if (FSOpenDir(pFSClient, pCmdBlock, path, &realHandle, (FSErrorFlag) this->getHandle()) == FS_STATUS_OK) {
|
||||
dirHandle->realDirHandle = realHandle;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Failed to open real dir %s", getName().c_str(), path);
|
||||
@ -49,12 +50,12 @@ FSStatus FSWrapperMergeDirsWithParent::FSReadDirWrapper(FSDirectoryHandle handle
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] No valid dir handle %08X", getName().c_str(), handle);
|
||||
return FS_STATUS_FATAL_ERROR;
|
||||
}
|
||||
auto *dirHandle = getDirExFromHandle(handle);
|
||||
auto dirHandle = getDirExFromHandle(handle);
|
||||
if (res == FS_STATUS_OK) {
|
||||
if (dirHandle->readResultCapacity == 0) {
|
||||
dirHandle->readResult = (FSDirectoryEntryEx *) malloc(sizeof(FSDirectoryEntryEx));
|
||||
if (dirHandle->readResult == nullptr) {
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] Failed to alloc memory for %08X (handle %08X)", getName().c_str(), dirHandle, handle);
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] Failed to alloc memory for %08X (handle %08X)", getName().c_str(), dirHandle.get(), handle);
|
||||
OSFatal("Failed to alloc memory for read result");
|
||||
}
|
||||
dirHandle->readResultCapacity = 1;
|
||||
@ -65,7 +66,7 @@ FSStatus FSWrapperMergeDirsWithParent::FSReadDirWrapper(FSDirectoryHandle handle
|
||||
dirHandle->readResult = (FSDirectoryEntryEx *) realloc(dirHandle->readResult, newCapacity * sizeof(FSDirectoryEntryEx));
|
||||
dirHandle->readResultCapacity = newCapacity;
|
||||
if (dirHandle->readResult == nullptr) {
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] Failed to realloc memory for %08X (handle %08X)", getName().c_str(), dirHandle, handle);
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] Failed to realloc memory for %08X (handle %08X)", getName().c_str(), dirHandle.get(), handle);
|
||||
OSFatal("Failed to alloc memory for read result");
|
||||
}
|
||||
}
|
||||
@ -92,8 +93,8 @@ FSStatus FSWrapperMergeDirsWithParent::FSReadDirWrapper(FSDirectoryHandle handle
|
||||
FSDirectoryEntry realDirEntry;
|
||||
FSStatus readDirResult;
|
||||
while (true) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Call real_FSReadDir for %08X with error_flag %08X", getName().c_str(), dirHandle->realDirHandle, (uint32_t) this);
|
||||
readDirResult = FSReadDir(pFSClient, pCmdBlock, dirHandle->realDirHandle, &realDirEntry, (FSErrorFlag) (uint32_t) this);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Call real_FSReadDir for %08X with error_flag %08X", getName().c_str(), dirHandle->realDirHandle, (uint32_t) this->getHandle());
|
||||
readDirResult = FSReadDir(pFSClient, pCmdBlock, dirHandle->realDirHandle, &realDirEntry, (FSErrorFlag) (uint32_t) this->getHandle());
|
||||
if (readDirResult == FS_STATUS_OK) {
|
||||
bool found = false;
|
||||
auto nameDeleted = deletePrefix + realDirEntry.name;
|
||||
@ -146,11 +147,11 @@ FSStatus FSWrapperMergeDirsWithParent::FSCloseDirWrapper(FSDirectoryHandle handl
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] No valid dir handle %08X", getName().c_str(), handle);
|
||||
return FS_STATUS_FATAL_ERROR;
|
||||
}
|
||||
auto *dirHandle = getDirExFromHandle(handle);
|
||||
auto dirHandle = getDirExFromHandle(handle);
|
||||
if (dirHandle->realDirHandle != 0) {
|
||||
if (pFSClient && pCmdBlock) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Call FSCloseDir for %08X with error_flag %08X (this)", getName().c_str(), dirHandle->realDirHandle, (uint32_t) this);
|
||||
auto realResult = FSCloseDir(pFSClient, pCmdBlock, dirHandle->realDirHandle, (FSErrorFlag) (uint32_t) this);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Call FSCloseDir for %08X with error_flag %08X (this)", getName().c_str(), dirHandle->realDirHandle, (uint32_t) this->getHandle());
|
||||
auto realResult = FSCloseDir(pFSClient, pCmdBlock, dirHandle->realDirHandle, (FSErrorFlag) (uint32_t) this->getHandle());
|
||||
if (realResult == FS_STATUS_OK) {
|
||||
dirHandle->realDirHandle = 0;
|
||||
} else {
|
||||
@ -181,7 +182,7 @@ FSStatus FSWrapperMergeDirsWithParent::FSRewindDirWrapper(FSDirectoryHandle hand
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] No valid dir handle %08X", getName().c_str(), handle);
|
||||
return FS_STATUS_FATAL_ERROR;
|
||||
}
|
||||
auto *dirHandle = getDirExFromHandle(handle);
|
||||
auto dirHandle = getDirExFromHandle(handle);
|
||||
if (dirHandle->readResult != nullptr) {
|
||||
dirHandle->readResultNumberOfEntries = 0;
|
||||
#pragma GCC diagnostic push
|
||||
@ -192,8 +193,8 @@ FSStatus FSWrapperMergeDirsWithParent::FSRewindDirWrapper(FSDirectoryHandle hand
|
||||
|
||||
if (dirHandle->realDirHandle != 0) {
|
||||
if (pFSClient && pCmdBlock) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Call real_FSRewindDir for %08X with error_flag %08X (this)", getName().c_str(), dirHandle->realDirHandle, (uint32_t) this);
|
||||
if (FSRewindDir(pFSClient, pCmdBlock, dirHandle->realDirHandle, (FSErrorFlag) (uint32_t) this) == FS_STATUS_OK) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Call real_FSRewindDir for %08X with error_flag %08X (this->getHandle())", getName().c_str(), dirHandle->realDirHandle, (uint32_t) this->getHandle());
|
||||
if (FSRewindDir(pFSClient, pCmdBlock, dirHandle->realDirHandle, (FSErrorFlag) (uint32_t) this->getHandle()) == FS_STATUS_OK) {
|
||||
dirHandle->realDirHandle = 0;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] Failed to rewind dir for realDirHandle %08X", getName().c_str(), dirHandle->realDirHandle);
|
||||
@ -242,16 +243,16 @@ void FSWrapperMergeDirsWithParent::freeFSClient() {
|
||||
pCmdBlock = nullptr;
|
||||
}
|
||||
|
||||
DirInfoEx *FSWrapperMergeDirsWithParent::getDirExFromHandle(FSDirectoryHandle handle) {
|
||||
auto *dir = getDirFromHandle(handle);
|
||||
auto res = dynamic_cast<DirInfoEx *>(dir);
|
||||
if (res == nullptr) {
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] dynamic_cast<DirInfoEx *>(%08X)", getName().c_str(), handle);
|
||||
OSFatal("dynamic_cast<DirInfoEx *> failed");
|
||||
std::shared_ptr<DirInfoEx> FSWrapperMergeDirsWithParent::getDirExFromHandle(FSDirectoryHandle handle) {
|
||||
auto dir = std::dynamic_pointer_cast<DirInfoEx>(getDirFromHandle(handle));
|
||||
|
||||
if (!dir) {
|
||||
DEBUG_FUNCTION_LINE_ERR("[%s] dynamic_pointer_cast<DirInfoEx *>(%08X) failed", getName().c_str(), handle);
|
||||
OSFatal("dynamic_pointer_cast<DirInfoEx *> failed");
|
||||
}
|
||||
return res;
|
||||
return dir;
|
||||
}
|
||||
|
||||
DirInfo *FSWrapperMergeDirsWithParent::getNewDirHandle() {
|
||||
return new (std::nothrow) DirInfoEx;
|
||||
std::shared_ptr<DirInfo> FSWrapperMergeDirsWithParent::getNewDirHandle() {
|
||||
return make_shared_nothrow<DirInfoEx>();
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
|
||||
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle) override;
|
||||
|
||||
DirInfo *getNewDirHandle() override;
|
||||
std::shared_ptr<DirInfo> getNewDirHandle() override;
|
||||
|
||||
bool SkipDeletedFilesInReadDir() override;
|
||||
|
||||
@ -32,5 +32,5 @@ private:
|
||||
FSClient *pFSClient;
|
||||
FSCmdBlock *pCmdBlock;
|
||||
|
||||
DirInfoEx *getDirExFromHandle(FSDirectoryHandle handle);
|
||||
std::shared_ptr<DirInfoEx> getDirExFromHandle(FSDirectoryHandle handle);
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ std::mutex workingDirMutex;
|
||||
std::map<FSClient *, std::string> workingDirs;
|
||||
|
||||
std::mutex fsLayerMutex;
|
||||
std::vector<IFSWrapper *> fsLayers;
|
||||
std::vector<std::unique_ptr<IFSWrapper>> fsLayers;
|
||||
|
||||
std::string getFullPathForClient(FSClient *pClient, char *path) {
|
||||
std::string res;
|
||||
@ -47,10 +47,7 @@ void clearFSLayer() {
|
||||
workingDirs.clear();
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> layerlock(fsLayerMutex);
|
||||
for (auto &layer : fsLayers) {
|
||||
delete layer;
|
||||
}
|
||||
std::lock_guard<std::mutex> layerLock(fsLayerMutex);
|
||||
fsLayers.clear();
|
||||
}
|
||||
}
|
||||
@ -61,15 +58,15 @@ void clearFSLayer() {
|
||||
FSStatus doForLayer(FSClient *client,
|
||||
FSErrorFlag errorMask,
|
||||
const std::function<FSStatus(FSErrorFlag errorMask)> &real_function,
|
||||
const std::function<FSStatus(IFSWrapper *layer)> &layer_callback,
|
||||
const std::function<FSStatus(IFSWrapper *layer, FSStatus)> &result_handler) {
|
||||
const std::function<FSStatus(std::unique_ptr<IFSWrapper> &layer)> &layer_callback,
|
||||
const std::function<FSStatus(std::unique_ptr<IFSWrapper> &layer, FSStatus)> &result_handler) {
|
||||
FSErrorFlag realErrorMask = errorMask;
|
||||
|
||||
std::lock_guard<std::mutex> lock(fsLayerMutex);
|
||||
if (!fsLayers.empty()) {
|
||||
uint32_t startIndex = fsLayers.size();
|
||||
for (uint32_t i = fsLayers.size(); i > 0; i--) {
|
||||
if ((uint32_t) fsLayers[i - 1] == errorMask) {
|
||||
if ((uint32_t) fsLayers[i - 1]->getHandle() == errorMask) {
|
||||
startIndex = i - 1;
|
||||
realErrorMask = FS_ERROR_FLAG_ALL;
|
||||
break;
|
||||
@ -78,7 +75,7 @@ FSStatus doForLayer(FSClient *client,
|
||||
|
||||
if (startIndex > 0) {
|
||||
for (uint32_t i = startIndex; i > 0; i--) {
|
||||
auto layer = fsLayers[i - 1];
|
||||
auto &layer = fsLayers[i - 1];
|
||||
if (!layer->isActive()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -8,16 +8,16 @@
|
||||
#include <string>
|
||||
|
||||
extern std::mutex fsLayerMutex;
|
||||
extern std::vector<IFSWrapper *> fsLayers;
|
||||
extern std::vector<std::unique_ptr<IFSWrapper>> fsLayers;
|
||||
|
||||
#define SYNC_RESULT_HANDLER [filename = __FILENAME__, func = __FUNCTION__, line = __LINE__]([[maybe_unused]] IFSWrapper *layer, FSStatus res) -> FSStatus { \
|
||||
DEBUG_FUNCTION_LINE_VERBOSE_EX(filename, func, line, "Sync result was %d", res); \
|
||||
return res; \
|
||||
#define SYNC_RESULT_HANDLER [filename = __FILENAME__, func = __FUNCTION__, line = __LINE__]([[maybe_unused]] std::unique_ptr<IFSWrapper> &layer, FSStatus res) -> FSStatus { \
|
||||
DEBUG_FUNCTION_LINE_VERBOSE_EX(filename, func, line, "Sync result was %d", res); \
|
||||
return res; \
|
||||
}
|
||||
|
||||
#define ASYNC_RESULT_HANDLER [c = client, b = block, a = asyncData, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__]([[maybe_unused]] IFSWrapper *layer, FSStatus res) -> FSStatus { \
|
||||
DEBUG_FUNCTION_LINE_VERBOSE_EX(filename, func, line, "Async result was %d", res); \
|
||||
return send_result_async(c, b, a, res); \
|
||||
#define ASYNC_RESULT_HANDLER [c = client, b = block, a = asyncData, filename = __FILENAME__, func = __FUNCTION__, line = __LINE__]([[maybe_unused]] std::unique_ptr<IFSWrapper> &layer, FSStatus res) -> FSStatus { \
|
||||
DEBUG_FUNCTION_LINE_VERBOSE_EX(filename, func, line, "Async result was %d", res); \
|
||||
return send_result_async(c, b, a, res); \
|
||||
}
|
||||
|
||||
#define FS_ERROR_FLAG_EXTRA_MASK (FSErrorFlag) 0xFFFF0000
|
||||
@ -68,8 +68,8 @@ void setWorkingDir(FSClient *client, const char *path);
|
||||
FSStatus doForLayer(FSClient *client,
|
||||
FSErrorFlag errorMask,
|
||||
const std::function<FSStatus(FSErrorFlag errorMask)> &real_function,
|
||||
const std::function<FSStatus(IFSWrapper *layer)> &layer_callback,
|
||||
const std::function<FSStatus(IFSWrapper *layer, FSStatus)> &result_handler);
|
||||
const std::function<FSStatus(std::unique_ptr<IFSWrapper> &layer)> &layer_callback,
|
||||
const std::function<FSStatus(std::unique_ptr<IFSWrapper> &layer, FSStatus)> &result_handler);
|
||||
|
||||
FSCmdBlockBody *fsCmdBlockGetBody(FSCmdBlock *cmdBlock);
|
||||
|
||||
|
@ -136,6 +136,10 @@ public:
|
||||
|
||||
virtual void deleteFileHandle(FSFileHandle handle) = 0;
|
||||
|
||||
uint32_t getHandle() {
|
||||
return (uint32_t) this;
|
||||
}
|
||||
|
||||
private:
|
||||
bool pIsActive = true;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "FileUtils.h"
|
||||
#include "IFSWrapper.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
#include <content_redirection/redirection.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <mutex>
|
||||
@ -13,13 +14,13 @@ ContentRedirectionApiErrorType CRAddFSLayer(CRLayerHandle *handle, const char *l
|
||||
DEBUG_FUNCTION_LINE_ERR("CONTENT_REDIRECTION_API_ERROR_INVALID_ARG");
|
||||
return CONTENT_REDIRECTION_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
IFSWrapper *ptr;
|
||||
std::unique_ptr<IFSWrapper> ptr;
|
||||
if (layerType == FS_LAYER_TYPE_CONTENT_REPLACE) {
|
||||
ptr = new (std::nothrow) FSWrapper(layerName, "/vol/content", replacementDir, false, false);
|
||||
ptr = make_unique_nothrow<FSWrapper>(layerName, "/vol/content", replacementDir, false, false);
|
||||
} else if (layerType == FS_LAYER_TYPE_CONTENT_MERGE) {
|
||||
ptr = new (std::nothrow) FSWrapperMergeDirsWithParent(layerName, "/vol/content", replacementDir, true);
|
||||
ptr = make_unique_nothrow<FSWrapperMergeDirsWithParent>(layerName, "/vol/content", replacementDir, true);
|
||||
} else if (layerType == FS_LAYER_TYPE_SAVE_REPLACE) {
|
||||
ptr = new (std::nothrow) FSWrapper(layerName, "/vol/save", replacementDir, false, true);
|
||||
ptr = make_unique_nothrow<FSWrapper>(layerName, "/vol/save", replacementDir, false, true);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_ERR("CONTENT_REDIRECTION_API_ERROR_UNKNOWN_LAYER_DIR_TYPE: %s %s %d", layerName, replacementDir, layerType);
|
||||
return CONTENT_REDIRECTION_API_ERROR_UNKNOWN_FS_LAYER_TYPE;
|
||||
@ -27,8 +28,8 @@ ContentRedirectionApiErrorType CRAddFSLayer(CRLayerHandle *handle, const char *l
|
||||
if (ptr) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Added new layer (%s). Replacement dir: %s Type:%d", layerName, replacementDir, layerType);
|
||||
std::lock_guard<std::mutex> lock(fsLayerMutex);
|
||||
fsLayers.push_back(ptr);
|
||||
*handle = (CRLayerHandle) ptr;
|
||||
*handle = (CRLayerHandle) ptr->getHandle();
|
||||
fsLayers.push_back(std::move(ptr));
|
||||
return CONTENT_REDIRECTION_API_ERROR_NONE;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate memory");
|
||||
@ -36,44 +37,24 @@ ContentRedirectionApiErrorType CRAddFSLayer(CRLayerHandle *handle, const char *l
|
||||
}
|
||||
|
||||
ContentRedirectionApiErrorType CRRemoveFSLayer(CRLayerHandle handle) {
|
||||
std::lock_guard<std::mutex> lock(fsLayerMutex);
|
||||
auto count = 0;
|
||||
auto found = false;
|
||||
IFSWrapper *layer;
|
||||
for (auto &cur : fsLayers) {
|
||||
if ((CRLayerHandle) cur == handle) {
|
||||
found = true;
|
||||
layer = cur;
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (!found) {
|
||||
if (remove_locked_first_if(fsLayerMutex, fsLayers, [handle](auto &cur) { return (CRLayerHandle) cur->getHandle() == handle; })) {
|
||||
DEBUG_FUNCTION_LINE_ERR("CONTENT_REDIRECTION_API_ERROR_LAYER_NOT_FOUND for handle %08X", handle);
|
||||
return CONTENT_REDIRECTION_API_ERROR_LAYER_NOT_FOUND;
|
||||
}
|
||||
fsLayers.erase(fsLayers.begin() + count);
|
||||
delete layer;
|
||||
return CONTENT_REDIRECTION_API_ERROR_NONE;
|
||||
}
|
||||
|
||||
ContentRedirectionApiErrorType CRSetActive(CRLayerHandle handle, bool active) {
|
||||
std::lock_guard<std::mutex> lock(fsLayerMutex);
|
||||
auto found = false;
|
||||
IFSWrapper *layer;
|
||||
for (auto &cur : fsLayers) {
|
||||
if ((CRLayerHandle) cur == handle) {
|
||||
found = true;
|
||||
layer = cur;
|
||||
break;
|
||||
if ((CRLayerHandle) cur->getHandle() == handle) {
|
||||
cur->setActive(active);
|
||||
return CONTENT_REDIRECTION_API_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
DEBUG_FUNCTION_LINE_ERR("CONTENT_REDIRECTION_API_ERROR_LAYER_NOT_FOUND for handle %08X", handle);
|
||||
return CONTENT_REDIRECTION_API_ERROR_LAYER_NOT_FOUND;
|
||||
}
|
||||
layer->setActive(active);
|
||||
return CONTENT_REDIRECTION_API_ERROR_NONE;
|
||||
|
||||
DEBUG_FUNCTION_LINE_ERR("CONTENT_REDIRECTION_API_ERROR_LAYER_NOT_FOUND for handle %08X", handle);
|
||||
return CONTENT_REDIRECTION_API_ERROR_LAYER_NOT_FOUND;
|
||||
}
|
||||
|
||||
uint32_t CRGetVersion() {
|
||||
|
@ -1,38 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <malloc.h>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
template<class T, class... Args>
|
||||
std::unique_ptr<T> make_unique_nothrow(Args &&...args) noexcept(noexcept(T(std::forward<Args>(args)...))) {
|
||||
return std::unique_ptr<T>(new (std::nothrow) T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
#define LIMIT(x, min, max) \
|
||||
({ \
|
||||
typeof(x) _x = x; \
|
||||
typeof(min) _min = min; \
|
||||
typeof(max) _max = max; \
|
||||
(((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
|
||||
: (_x)); \
|
||||
})
|
||||
template<class T, class... Args>
|
||||
std::shared_ptr<T> make_shared_nothrow(Args &&...args) noexcept(noexcept(T(std::forward<Args>(args)...))) {
|
||||
return std::shared_ptr<T>(new (std::nothrow) T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
#define DegToRad(a) ((a) *0.01745329252f)
|
||||
#define RadToDeg(a) ((a) *57.29577951f)
|
||||
|
||||
#define ALIGN4(x) (((x) + 3) & ~3)
|
||||
#define ALIGN32(x) (((x) + 31) & ~31)
|
||||
template<typename T, class Allocator, class Predicate>
|
||||
bool remove_locked_first_if(std::mutex &mutex, std::vector<T, Allocator> &list, Predicate pred) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
auto it = list.begin();
|
||||
while (it != list.end()) {
|
||||
if (pred(*it)) {
|
||||
list.erase(it);
|
||||
return true;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// those work only in powers of 2
|
||||
#define ROUNDDOWN(val, align) ((val) & ~(align - 1))
|
||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
|
||||
|
||||
|
||||
#define le16(i) ((((uint16_t) ((i) &0xFF)) << 8) | ((uint16_t) (((i) &0xFF00) >> 8)))
|
||||
#define le32(i) ((((uint32_t) le16((i) &0xFFFF)) << 16) | ((uint32_t) le16(((i) &0xFFFF0000) >> 16)))
|
||||
#define le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32)))
|
||||
|
||||
//Needs to have log_init() called beforehand.
|
||||
void dumpHex(const void *data, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
|
Loading…
x
Reference in New Issue
Block a user