mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-05 07:25:16 +00:00
refactor: nuke all widestrings and widechars everywhere
This commit is contained in:
@@ -7,19 +7,19 @@ class EOFException : public std::exception {};
|
||||
|
||||
class IllegalArgumentException : public std::exception {
|
||||
public:
|
||||
std::wstring information;
|
||||
std::string information;
|
||||
|
||||
IllegalArgumentException(const std::wstring& information);
|
||||
IllegalArgumentException(const std::string& information);
|
||||
};
|
||||
|
||||
class IOException : public std::exception {
|
||||
public:
|
||||
std::wstring information;
|
||||
std::string information;
|
||||
|
||||
IOException(const std::wstring& information);
|
||||
IOException(const std::string& information);
|
||||
};
|
||||
|
||||
class RuntimeException : public std::exception {
|
||||
public:
|
||||
RuntimeException(const std::wstring& information);
|
||||
RuntimeException(const std::string& information);
|
||||
};
|
||||
@@ -11,16 +11,16 @@ class FileFilter;
|
||||
class File {
|
||||
public:
|
||||
// The system-dependent path-separator character
|
||||
static const wchar_t pathSeparator;
|
||||
static const char pathSeparator;
|
||||
|
||||
// 4J Jev, the start of the file root
|
||||
static const std::wstring pathRoot;
|
||||
static const std::string pathRoot;
|
||||
|
||||
File() { m_abstractPathName = L""; }
|
||||
File() { m_abstractPathName = ""; }
|
||||
|
||||
File(const File& parent, const std::wstring& child);
|
||||
File(const std::wstring& pathname);
|
||||
File(const std::wstring& parent, const std::wstring& child);
|
||||
File(const File& parent, const std::string& child);
|
||||
File(const std::string& pathname);
|
||||
File(const std::string& parent, const std::string& child);
|
||||
bool _delete();
|
||||
bool mkdir() const;
|
||||
bool mkdirs() const;
|
||||
@@ -32,19 +32,19 @@ public:
|
||||
bool isDirectory() const;
|
||||
int64_t length();
|
||||
int64_t lastModified();
|
||||
const std::wstring getPath() const; // 4J Jev: TODO
|
||||
std::wstring getName() const;
|
||||
const std::string getPath() const; // 4J Jev: TODO
|
||||
std::string getName() const;
|
||||
|
||||
static int hash_fnct(const File& k);
|
||||
static bool eq_test(const File& x, const File& y);
|
||||
|
||||
private:
|
||||
void _init();
|
||||
std::wstring m_abstractPathName;
|
||||
std::string m_abstractPathName;
|
||||
|
||||
// 4J Jev, just helper functions, change between paths and
|
||||
// std::vector<string>
|
||||
// File(std::vector<std::wstring> *path);
|
||||
// File(std::vector<std::string> *path);
|
||||
};
|
||||
|
||||
struct FileKeyHash {
|
||||
|
||||
@@ -7,5 +7,5 @@ class File;
|
||||
// 4J Jev, java lirary interface.
|
||||
class FilenameFilter {
|
||||
public:
|
||||
virtual bool accept(File* dir, const std::wstring& name) = 0;
|
||||
virtual bool accept(File* dir, const std::string& name) = 0;
|
||||
};
|
||||
@@ -7,7 +7,7 @@
|
||||
class BufferedReader : public Reader {
|
||||
private:
|
||||
Reader* reader;
|
||||
wchar_t* buffer;
|
||||
char* buffer;
|
||||
|
||||
unsigned int readMark;
|
||||
unsigned int bufferedMark;
|
||||
@@ -23,6 +23,6 @@ public:
|
||||
|
||||
virtual void close();
|
||||
virtual int read();
|
||||
virtual int read(wchar_t cbuf[], unsigned int off, unsigned int len);
|
||||
std::wstring readLine();
|
||||
virtual int read(char cbuf[], unsigned int off, unsigned int len);
|
||||
std::string readLine();
|
||||
};
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
virtual int readInt() = 0;
|
||||
virtual int64_t readLong() = 0;
|
||||
virtual short readShort() = 0;
|
||||
virtual wchar_t readChar() = 0;
|
||||
virtual std::wstring readUTF() = 0;
|
||||
virtual char readChar() = 0;
|
||||
virtual std::string readUTF() = 0;
|
||||
virtual unsigned long long readPlayerUID() = 0; // 4J Added
|
||||
virtual int skipBytes(int n) = 0;
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
virtual bool readBoolean();
|
||||
virtual uint8_t readByte();
|
||||
virtual unsigned char readUnsignedByte();
|
||||
virtual wchar_t readChar();
|
||||
virtual char readChar();
|
||||
virtual bool readFully(std::vector<uint8_t>& b);
|
||||
virtual bool readFully(std::vector<char>& b);
|
||||
virtual double readDouble();
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
virtual int64_t readLong();
|
||||
virtual short readShort();
|
||||
virtual unsigned short readUnsignedShort();
|
||||
virtual std::wstring readUTF();
|
||||
virtual std::string readUTF();
|
||||
void deleteChildStream();
|
||||
virtual int readUTFChar();
|
||||
virtual unsigned long long readPlayerUID(); // 4J Added
|
||||
|
||||
@@ -17,8 +17,8 @@ public:
|
||||
virtual void writeLong(int64_t a) = 0;
|
||||
virtual void writeShort(short a) = 0;
|
||||
virtual void writeBoolean(bool v) = 0;
|
||||
virtual void writeChar(wchar_t v) = 0;
|
||||
virtual void writeChars(const std::wstring& s) = 0;
|
||||
virtual void writeUTF(const std::wstring& a) = 0;
|
||||
virtual void writeChar(char v) = 0;
|
||||
virtual void writeChars(const std::string& s) = 0;
|
||||
virtual void writeUTF(const std::string& a) = 0;
|
||||
virtual void writePlayerUID(unsigned long long player) = 0; // 4J Added
|
||||
};
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
virtual void writeLong(int64_t a);
|
||||
virtual void writeShort(short a);
|
||||
virtual void writeUnsignedShort(unsigned short a);
|
||||
virtual void writeChar(wchar_t a);
|
||||
virtual void writeChars(const std::wstring& a);
|
||||
virtual void writeChar(char a);
|
||||
virtual void writeChars(const std::string& a);
|
||||
virtual void writeBoolean(bool b);
|
||||
virtual void writeUTF(const std::wstring& a);
|
||||
virtual void writeUTF(const std::string& a);
|
||||
virtual void writePlayerUID(unsigned long long player);
|
||||
virtual void flush();
|
||||
};
|
||||
@@ -17,5 +17,5 @@ public:
|
||||
virtual void close() = 0;
|
||||
virtual int64_t skip(int64_t n) = 0;
|
||||
|
||||
static InputStream* getResourceAsStream(const std::wstring& fileName);
|
||||
static InputStream* getResourceAsStream(const std::string& fileName);
|
||||
};
|
||||
@@ -15,5 +15,5 @@ public:
|
||||
|
||||
virtual void close();
|
||||
virtual int read();
|
||||
virtual int read(wchar_t cbuf[], unsigned int offset, unsigned int length);
|
||||
virtual int read(char cbuf[], unsigned int offset, unsigned int length);
|
||||
};
|
||||
@@ -8,6 +8,6 @@ public:
|
||||
// resources associated with it.
|
||||
virtual int read() = 0; // Reads a single character.
|
||||
virtual int read(
|
||||
wchar_t cbuf[], unsigned int off,
|
||||
char cbuf[], unsigned int off,
|
||||
unsigned int len) = 0; // Reads characters into a portion of an array.
|
||||
};
|
||||
@@ -42,5 +42,5 @@ public:
|
||||
static void ReverseULONG(unsigned int* pulVal);
|
||||
static void ReverseINT(int* piVal);
|
||||
static void ReverseULONGLONG(int64_t* pullVal);
|
||||
static void ReverseWCHARA(wchar_t* pwch, int iLen);
|
||||
static void ReverseWCHARA(char* pwch, int iLen);
|
||||
};
|
||||
|
||||
@@ -12,21 +12,21 @@
|
||||
#include "platform/fs/fs.h"
|
||||
#include "java/FileFilter.h"
|
||||
|
||||
const wchar_t File::pathSeparator = L'/';
|
||||
const char File::pathSeparator = '/';
|
||||
|
||||
const std::wstring File::pathRoot =
|
||||
L""; // Path root after pathSeparator has been removed
|
||||
const std::string File::pathRoot =
|
||||
""; // Path root after pathSeparator has been removed
|
||||
|
||||
namespace {
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
fs::path ToFilesystemPath(const std::wstring& path) {
|
||||
fs::path ToFilesystemPath(const std::string& path) {
|
||||
return fs::path(path);
|
||||
}
|
||||
|
||||
std::wstring ToFilename(const fs::path& path) {
|
||||
std::string ToFilename(const fs::path& path) {
|
||||
const std::string filename = path.filename().string();
|
||||
return filenametowstring(filename.c_str());
|
||||
return filename;
|
||||
}
|
||||
|
||||
int64_t ToEpochMilliseconds(const fs::file_time_type& fileTime) {
|
||||
@@ -40,27 +40,27 @@ int64_t ToEpochMilliseconds(const fs::file_time_type& fileTime) {
|
||||
|
||||
// Creates a new File instance from a parent abstract pathname and a child
|
||||
// pathname string.
|
||||
File::File(const File& parent, const std::wstring& child) {
|
||||
File::File(const File& parent, const std::string& child) {
|
||||
m_abstractPathName = parent.getPath() + pathSeparator + child;
|
||||
}
|
||||
|
||||
// Creates a new File instance by converting the given pathname string into an
|
||||
// abstract pathname.
|
||||
|
||||
File::File(const std::wstring& pathname) {
|
||||
File::File(const std::string& pathname) {
|
||||
if (pathname.empty()) {
|
||||
m_abstractPathName = L"";
|
||||
m_abstractPathName = "";
|
||||
return;
|
||||
}
|
||||
|
||||
std::wstring fixedPath = pathname;
|
||||
std::string fixedPath = pathname;
|
||||
for (size_t i = 0; i < fixedPath.length(); ++i) {
|
||||
if (fixedPath[i] == L'\\') fixedPath[i] = L'/';
|
||||
if (fixedPath[i] == '\\') fixedPath[i] = '/';
|
||||
}
|
||||
size_t dpos;
|
||||
while ((dpos = fixedPath.find(L"//")) != std::wstring::npos)
|
||||
while ((dpos = fixedPath.find("//")) != std::string::npos)
|
||||
fixedPath.erase(dpos, 1);
|
||||
if (fixedPath.find(L"GAME:/") == 0) fixedPath = fixedPath.substr(6);
|
||||
if (fixedPath.find("GAME:/") == 0) fixedPath = fixedPath.substr(6);
|
||||
m_abstractPathName = fixedPath;
|
||||
|
||||
#if defined(__linux__)
|
||||
@@ -85,11 +85,11 @@ File::File(const std::wstring& pathname) {
|
||||
std::string tryFull = exeDir + base + request;
|
||||
std::string tryFile = exeDir + base + fileName;
|
||||
if (PlatformFilesystem.exists(tryFull)) {
|
||||
m_abstractPathName = convStringToWstring(tryFull);
|
||||
m_abstractPathName = tryFull;
|
||||
return;
|
||||
}
|
||||
if (PlatformFilesystem.exists(tryFile)) {
|
||||
m_abstractPathName = convStringToWstring(tryFile);
|
||||
m_abstractPathName = tryFile;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -99,15 +99,15 @@ File::File(const std::wstring& pathname) {
|
||||
std::string path = std::filesystem::path(m_abstractPathName).string();
|
||||
std::string finalPath = PlatformStorage.GetMountedPath(path.c_str());
|
||||
if (finalPath.size() == 0) finalPath = path;
|
||||
m_abstractPathName = convStringToWstring(finalPath);
|
||||
m_abstractPathName = finalPath;
|
||||
#endif
|
||||
/*
|
||||
std::vector<std::wstring> path = stringSplit( pathname, pathSeparator );
|
||||
std::vector<std::string> path = stringSplit( pathname, pathSeparator );
|
||||
|
||||
if( path.back().compare( pathRoot ) != 0 )
|
||||
m_abstractPathName = path.back();
|
||||
else
|
||||
m_abstractPathName = L"";
|
||||
m_abstractPathName = "";
|
||||
|
||||
path.pop_back();
|
||||
|
||||
@@ -122,8 +122,8 @@ File::File(const std::wstring& pathname) {
|
||||
*/
|
||||
}
|
||||
|
||||
File::File(const std::wstring& parent,
|
||||
const std::wstring& child) //: m_abstractPathName( child )
|
||||
File::File(const std::string& parent,
|
||||
const std::string& child) //: m_abstractPathName( child )
|
||||
{
|
||||
m_abstractPathName =
|
||||
pathRoot + pathSeparator + parent + pathSeparator + child;
|
||||
@@ -133,7 +133,7 @@ File::File(const std::wstring& parent,
|
||||
// Creates a new File instance by converting the given path vector into an
|
||||
// abstract pathname.
|
||||
/*
|
||||
File::File( std::vector<std::wstring> *path ) : parent( nullptr )
|
||||
File::File( std::vector<std::string> *path ) : parent( nullptr )
|
||||
{
|
||||
m_abstractPathName = path->back();
|
||||
path->pop_back();
|
||||
@@ -363,13 +363,13 @@ int64_t File::lastModified() {
|
||||
return 0l;
|
||||
}
|
||||
|
||||
const std::wstring File::getPath() const {
|
||||
const std::string File::getPath() const {
|
||||
/*
|
||||
std::wstring path;
|
||||
std::string path;
|
||||
if ( parent != nullptr)
|
||||
path = parent->getPath();
|
||||
else
|
||||
path = std::wstring(pathRoot);
|
||||
path = std::string(pathRoot);
|
||||
|
||||
path.push_back( pathSeparator );
|
||||
path.append(m_abstractPathName);
|
||||
@@ -377,7 +377,7 @@ const std::wstring File::getPath() const {
|
||||
return m_abstractPathName;
|
||||
}
|
||||
|
||||
std::wstring File::getName() const {
|
||||
std::string File::getName() const {
|
||||
unsigned int sep =
|
||||
(unsigned int)(m_abstractPathName.find_last_of(this->pathSeparator));
|
||||
return m_abstractPathName.substr(sep + 1, m_abstractPathName.length());
|
||||
@@ -394,7 +394,7 @@ int File::hash_fnct(const File& k) {
|
||||
// if (k->parent != nullptr)
|
||||
// hashCode = hash_fnct(k->getParent());
|
||||
|
||||
wchar_t* ref = (wchar_t*)k.m_abstractPathName.c_str();
|
||||
char* ref = (char*)k.m_abstractPathName.c_str();
|
||||
|
||||
for (unsigned int i = 0; i < k.m_abstractPathName.length(); i++) {
|
||||
hashCode += ((hashCode * 33) + ref[i]) % 149;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
BufferedReader::BufferedReader(Reader* in)
|
||||
: reader(in), readMark(0), bufferedMark(0), eofReached(false) {
|
||||
bufferSize = 64;
|
||||
buffer = new wchar_t[bufferSize];
|
||||
memset(buffer, 0, sizeof(wchar_t) * bufferSize);
|
||||
buffer = new char[bufferSize];
|
||||
memset(buffer, 0, sizeof(char) * bufferSize);
|
||||
bufferMore();
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ void BufferedReader::bufferMore() {
|
||||
|
||||
if (bufferSize < (bufferedMark + BUFFER_MORE_AMOUNT)) {
|
||||
// Enlarge the buffer
|
||||
wchar_t* temp = new wchar_t[bufferSize * 2];
|
||||
memset(temp, 0, sizeof(wchar_t) * bufferSize * 2);
|
||||
char* temp = new char[bufferSize * 2];
|
||||
memset(temp, 0, sizeof(char) * bufferSize * 2);
|
||||
std::copy(buffer, buffer + bufferSize, temp);
|
||||
|
||||
delete[] buffer;
|
||||
@@ -99,11 +99,11 @@ int BufferedReader::read() {
|
||||
// Returns:
|
||||
// The number of characters read, or -1 if the end of the stream has been
|
||||
// reached
|
||||
int BufferedReader::read(wchar_t cbuf[], unsigned int off, unsigned int len) {
|
||||
int BufferedReader::read(char cbuf[], unsigned int off, unsigned int len) {
|
||||
if (bufferSize < (bufferedMark + len)) {
|
||||
// Enlarge the buffer
|
||||
wchar_t* temp = new wchar_t[bufferSize * 2];
|
||||
memset(temp, 0, sizeof(wchar_t) * bufferSize * 2);
|
||||
char* temp = new char[bufferSize * 2];
|
||||
memset(temp, 0, sizeof(char) * bufferSize * 2);
|
||||
std::copy(buffer, buffer + bufferSize, temp);
|
||||
|
||||
delete[] buffer;
|
||||
@@ -135,12 +135,12 @@ int BufferedReader::read(wchar_t cbuf[], unsigned int off, unsigned int len) {
|
||||
// immediately by a linefeed. Returns: A String containing the contents of the
|
||||
// line, not including any line-termination characters, or null if the end of
|
||||
// the stream has been reached
|
||||
std::wstring BufferedReader::readLine() {
|
||||
std::wstring output = L"";
|
||||
std::string BufferedReader::readLine() {
|
||||
std::string output = "";
|
||||
bool newLineCharFound = false;
|
||||
|
||||
while (readMark < bufferedMark) {
|
||||
wchar_t value = buffer[readMark++];
|
||||
char value = buffer[readMark++];
|
||||
|
||||
if (!newLineCharFound) {
|
||||
if ((value == '\n') || (value == '\r')) {
|
||||
|
||||
@@ -162,7 +162,7 @@ unsigned char DataInputStream::readUnsignedByte() {
|
||||
//
|
||||
// This method is suitable for reading bytes written by the writeChar method of
|
||||
// interface DataOutput. Returns: the char value read.
|
||||
wchar_t DataInputStream::readChar() {
|
||||
char DataInputStream::readChar() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(
|
||||
stderr,
|
||||
@@ -171,7 +171,7 @@ wchar_t DataInputStream::readChar() {
|
||||
}
|
||||
int a = stream->read();
|
||||
int b = stream->read();
|
||||
return (wchar_t)((a << 8) | (b & 0xff));
|
||||
return (char)((a << 8) | (b & 0xff));
|
||||
}
|
||||
|
||||
// Reads some bytes from an input stream and stores them into the buffer array
|
||||
@@ -399,8 +399,8 @@ unsigned short DataInputStream::readUnsignedShort() {
|
||||
//
|
||||
// Returns:
|
||||
// a Unicode string.
|
||||
std::wstring DataInputStream::readUTF() {
|
||||
std::wstring outputString;
|
||||
std::string DataInputStream::readUTF() {
|
||||
std::string outputString;
|
||||
if (stream == nullptr) {
|
||||
fprintf(
|
||||
stderr,
|
||||
@@ -413,11 +413,11 @@ std::wstring DataInputStream::readUTF() {
|
||||
|
||||
//// 4J Stu - I decided while writing DataOutputStream that we didn't need
|
||||
/// to bother using the UTF8 format / used in the java libs, and just write
|
||||
/// in/out as wchar_t all the time
|
||||
/// in/out as char all the time
|
||||
|
||||
/*for( unsigned short i = 0; i < UTFLength; i++)
|
||||
{
|
||||
wchar_t theChar = readChar();
|
||||
char theChar = readChar();
|
||||
outputString.push_back(theChar);
|
||||
}*/
|
||||
|
||||
@@ -447,7 +447,7 @@ std::wstring DataInputStream::readUTF() {
|
||||
break;
|
||||
} else if ((firstByte & 0x80) == 0x00) {
|
||||
// One byte UTF
|
||||
wchar_t readChar = (wchar_t)firstByte;
|
||||
char readChar = (char)firstByte;
|
||||
outputString.push_back(readChar);
|
||||
continue;
|
||||
} else if ((firstByte & 0xE0) == 0xC0) {
|
||||
@@ -473,8 +473,8 @@ std::wstring DataInputStream::readUTF() {
|
||||
break;
|
||||
}
|
||||
|
||||
wchar_t readChar =
|
||||
(wchar_t)(((firstByte & 0x1F) << 6) | (secondByte & 0x3F));
|
||||
char readChar =
|
||||
(char)(((firstByte & 0x1F) << 6) | (secondByte & 0x3F));
|
||||
outputString.push_back(readChar);
|
||||
continue;
|
||||
} else if ((firstByte & 0xF0) == 0xE0) {
|
||||
@@ -516,8 +516,8 @@ std::wstring DataInputStream::readUTF() {
|
||||
break;
|
||||
}
|
||||
|
||||
wchar_t readChar =
|
||||
(wchar_t)(((firstByte & 0x0F) << 12) |
|
||||
char readChar =
|
||||
(char)(((firstByte & 0x0F) << 12) |
|
||||
((secondByte & 0x3F) << 6) | (thirdByte & 0x3F));
|
||||
outputString.push_back(readChar);
|
||||
continue;
|
||||
|
||||
@@ -173,7 +173,7 @@ void DataOutputStream::writeUnsignedShort(unsigned short a) {
|
||||
// first. If no exception is thrown, the counter written is incremented by 2.
|
||||
// Parameters:
|
||||
// v - a char value to be written.
|
||||
void DataOutputStream::writeChar(wchar_t v) {
|
||||
void DataOutputStream::writeChar(char v) {
|
||||
stream->write((v >> 8) & 0xff);
|
||||
stream->write(v & 0xff);
|
||||
// TODO 4J Stu - Error handling?
|
||||
@@ -184,7 +184,7 @@ void DataOutputStream::writeChar(wchar_t v) {
|
||||
// Each character is written to the data output stream as if by the writeChar
|
||||
// method. If no exception is thrown, the counter written is incremented by
|
||||
// twice the length of s. Parameters: s - a String value to be written.
|
||||
void DataOutputStream::writeChars(const std::wstring& str) {
|
||||
void DataOutputStream::writeChars(const std::string& str) {
|
||||
for (unsigned int i = 0; i < str.length(); i++) {
|
||||
writeChar(str.at(i));
|
||||
// TODO 4J Stu - Error handling?
|
||||
@@ -212,7 +212,7 @@ void DataOutputStream::writeBoolean(bool b) {
|
||||
// of bytes written to the output stream. This will be at least two plus the
|
||||
// length of str, and at most two plus thrice the length of str. Parameters: str
|
||||
// - a string to be written.
|
||||
void DataOutputStream::writeUTF(const std::wstring& str) {
|
||||
void DataOutputStream::writeUTF(const std::string& str) {
|
||||
int strlen = (int)str.length();
|
||||
int utflen = 0;
|
||||
int c, count = 0;
|
||||
|
||||
@@ -51,7 +51,7 @@ bool FileSeek(std::FILE* file, int64_t offset, int origin) {
|
||||
// denies read access to the file.
|
||||
FileInputStream::FileInputStream(const File& file) : m_fileHandle(nullptr) {
|
||||
#if defined(_WIN32)
|
||||
m_fileHandle = _wfopen(file.getPath().c_str(), L"rb");
|
||||
m_fileHandle = _wfopen(file.getPath().c_str(), "rb");
|
||||
#else
|
||||
const std::string nativePath = std::filesystem::path(file.getPath()).string();
|
||||
m_fileHandle = std::fopen(nativePath.c_str(), "rb");
|
||||
|
||||
@@ -28,7 +28,7 @@ FileOutputStream::FileOutputStream(const File& file) : m_fileHandle(nullptr) {
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
m_fileHandle = _wfopen(file.getPath().c_str(), L"wb");
|
||||
m_fileHandle = _wfopen(file.getPath().c_str(), "wb");
|
||||
#else
|
||||
const std::string nativePath = std::filesystem::path(file.getPath()).string();
|
||||
m_fileHandle = std::fopen(nativePath.c_str(), "wb");
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "java/File.h"
|
||||
#include "java/InputOutputStream/FileInputStream.h"
|
||||
|
||||
InputStream* InputStream::getResourceAsStream(const std::wstring& fileName) {
|
||||
InputStream* InputStream::getResourceAsStream(const std::string& fileName) {
|
||||
File file(fileName);
|
||||
return file.exists() ? new FileInputStream(file) : nullptr;
|
||||
}
|
||||
@@ -29,11 +29,11 @@ int InputStreamReader::read() { return stream->readUTFChar(); }
|
||||
// Returns:
|
||||
// The number of characters read, or -1 if the end of the stream has been
|
||||
// reached
|
||||
int InputStreamReader::read(wchar_t cbuf[], unsigned int offset,
|
||||
int InputStreamReader::read(char cbuf[], unsigned int offset,
|
||||
unsigned int length) {
|
||||
unsigned int charsRead = 0;
|
||||
for (unsigned int i = offset; i < offset + length; i++) {
|
||||
wchar_t value = (wchar_t)stream->readUTFChar();
|
||||
char value = (char)stream->readUTFChar();
|
||||
if (value != -1) {
|
||||
cbuf[i] = value;
|
||||
charsRead++;
|
||||
|
||||
@@ -156,7 +156,7 @@ void System::ReverseULONGLONG(int64_t* pullVal) {
|
||||
pchVal1[7] = pchVal2[0];
|
||||
}
|
||||
|
||||
void System::ReverseWCHARA(wchar_t* pwch, int iLen) {
|
||||
void System::ReverseWCHARA(char* pwch, int iLen) {
|
||||
for (int i = 0; i < iLen; i++) {
|
||||
ReverseUSHORT((unsigned short*)&pwch[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user