mirror of
https://github.com/AxioDL/nod.git
synced 2025-08-09 05:29:18 +00:00
Additional windows additions
This commit is contained in:
parent
044a393ff8
commit
9ce2e0a3b2
@ -281,7 +281,7 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo
|
|||||||
|
|
||||||
static inline int FSeek(FILE* fp, int64_t offset, int whence)
|
static inline int FSeek(FILE* fp, int64_t offset, int whence)
|
||||||
{
|
{
|
||||||
#if NOD_UCS2
|
#if _WIN32
|
||||||
return _fseeki64(fp, offset, whence);
|
return _fseeki64(fp, offset, whence);
|
||||||
#elif __APPLE__ || __FreeBSD__
|
#elif __APPLE__ || __FreeBSD__
|
||||||
return fseeko(fp, offset, whence);
|
return fseeko(fp, offset, whence);
|
||||||
|
@ -8,6 +8,29 @@
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
static void* memmem(const void *haystack, size_t hlen, const void *needle, size_t nlen)
|
||||||
|
{
|
||||||
|
int needle_first;
|
||||||
|
const uint8_t *p = static_cast<const uint8_t*>(haystack);
|
||||||
|
size_t plen = hlen;
|
||||||
|
|
||||||
|
if (!nlen)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
needle_first = *(unsigned char *)needle;
|
||||||
|
|
||||||
|
while (plen >= nlen && (p = static_cast<const uint8_t*>(memchr(p, needle_first, plen - nlen + 1))))
|
||||||
|
{
|
||||||
|
if (!memcmp(p, needle, nlen))
|
||||||
|
return (void *)p;
|
||||||
|
|
||||||
|
p++;
|
||||||
|
plen = hlen - (p - static_cast<const uint8_t*>(haystack));
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -320,30 +343,9 @@ bool DiscBuilderBase::PartitionBuilderBase::buildFromDirectory(IPartWriteStream&
|
|||||||
uint64_t fileOff = userAllocate(fileSz, ws);
|
uint64_t fileOff = userAllocate(fileSz, ws);
|
||||||
m_dolOffset = fileOff;
|
m_dolOffset = fileOff;
|
||||||
m_dolSize = fileSz;
|
m_dolSize = fileSz;
|
||||||
<<<<<<< HEAD
|
|
||||||
std::unique_ptr<IFileIO::IReadStream> rs = NewFileIO(dolIn)->beginReadStream();
|
std::unique_ptr<IFileIO::IReadStream> rs = NewFileIO(dolIn)->beginReadStream();
|
||||||
size_t xferSz = PatchDOL(*rs, ws, dolStat.st_size);
|
size_t xferSz = PatchDOL(*rs, ws, dolStat.st_size);
|
||||||
m_parent.m_progressCB(++m_parent.m_progressIdx, SystemString(dolIn) + _S(" [PATCHED]"), xferSz);
|
m_parent.m_progressCB(++m_parent.m_progressIdx, SystemString(dolIn) + _S(" [PATCHED]"), xferSz);
|
||||||
=======
|
|
||||||
std::unique_ptr<IFileIO::IWriteStream> ws = m_parent.getFileIO().beginWriteStream(fileOff);
|
|
||||||
FILE* fp = Fopen(dolIn, _S("rb"), FileLockType::Read);
|
|
||||||
if (!fp)
|
|
||||||
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for reading"), dolIn);
|
|
||||||
char buf[8192];
|
|
||||||
size_t xferSz = 0;
|
|
||||||
SystemString dolName(dolIn);
|
|
||||||
++m_parent.m_progressIdx;
|
|
||||||
while (xferSz < dolStat.st_size)
|
|
||||||
{
|
|
||||||
size_t rdSz = fread(buf, 1, NOD::min(size_t(8192), dolStat.st_size - xferSz), fp);
|
|
||||||
if (!rdSz)
|
|
||||||
break;
|
|
||||||
ws->write(buf, rdSz);
|
|
||||||
xferSz += rdSz;
|
|
||||||
m_parent.m_progressCB(m_parent.m_progressIdx, dolName, xferSz);
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
>>>>>>> 1c740a3da8495cfaebb7dc648602b9273c097a74
|
|
||||||
for (size_t i=0 ; i<fileSz-xferSz ; ++i)
|
for (size_t i=0 ; i<fileSz-xferSz ; ++i)
|
||||||
ws.write("\xff", 1);
|
ws.write("\xff", 1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user