mirror of
https://github.com/zeldaret/ss
synced 2026-09-01 09:32:58 -04:00
ut_FileStream
thanks ogws
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#include <nw4r/ut.h>
|
||||
|
||||
namespace nw4r {
|
||||
namespace ut {
|
||||
|
||||
NW4R_UT_RTTI_DEF_DERIVED(FileStream, IOStream);
|
||||
|
||||
void FileStream::Cancel() {}
|
||||
|
||||
bool FileStream::CancelAsync(AsyncCallback callback, void *arg) {
|
||||
#pragma unused(callback)
|
||||
#pragma unused(arg)
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 FileStream::FilePosition::Skip(long offset) {
|
||||
if (offset != 0) {
|
||||
s64 newOffset = mFileOffset + offset;
|
||||
mFileOffset = Clamp<s64>(newOffset, 0, mFileSize);
|
||||
}
|
||||
|
||||
return mFileOffset;
|
||||
}
|
||||
|
||||
u32 FileStream::FilePosition::Append(long offset) {
|
||||
s64 newOffset = mFileOffset + offset;
|
||||
|
||||
if (newOffset < 0) {
|
||||
mFileOffset = 0;
|
||||
} else {
|
||||
mFileOffset = newOffset;
|
||||
mFileSize = Max(mFileOffset, mFileSize);
|
||||
}
|
||||
|
||||
return mFileOffset;
|
||||
}
|
||||
|
||||
void FileStream::FilePosition::Seek(long offset, unsigned long origin) {
|
||||
switch (origin) {
|
||||
case SEEK_BEG:
|
||||
mFileOffset = 0;
|
||||
break;
|
||||
case SEEK_END:
|
||||
mFileOffset = mFileSize;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Skip(offset);
|
||||
}
|
||||
|
||||
// TODO: This should not be necessary. Because of nw4r::snd? still the case for ss
|
||||
DECOMP_FORCEACTIVE(ut_FileStream_cpp, FileStream::GetRuntimeTypeInfo);
|
||||
|
||||
} // namespace ut
|
||||
} // namespace nw4r
|
||||
|
||||
Reference in New Issue
Block a user