summaryrefslogtreecommitdiff
path: root/tools/scaninc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/scaninc')
-rw-r--r--tools/scaninc/asm_file.cpp12
-rw-r--r--tools/scaninc/c_file.cpp54
-rw-r--r--tools/scaninc/c_file.h1
-rw-r--r--tools/scaninc/scaninc.cpp6
4 files changed, 15 insertions, 58 deletions
diff --git a/tools/scaninc/asm_file.cpp b/tools/scaninc/asm_file.cpp
index 143c70242..c3d140bb1 100644
--- a/tools/scaninc/asm_file.cpp
+++ b/tools/scaninc/asm_file.cpp
@@ -27,23 +27,23 @@ AsmFile::AsmFile(std::string path)
{
m_path = path;
- FILE *fp = fopen(path.c_str(), "rb");
+ FILE *fp = std::fopen(path.c_str(), "rb");
if (fp == NULL)
FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
- fseek(fp, 0, SEEK_END);
+ std::fseek(fp, 0, SEEK_END);
- m_size = ftell(fp);
+ m_size = std::ftell(fp);
m_buffer = new char[m_size];
- rewind(fp);
+ std::rewind(fp);
- if (fread(m_buffer, m_size, 1, fp) != 1)
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
FATAL_ERROR("Failed to read \"%s\".\n", path.c_str());
- fclose(fp);
+ std::fclose(fp);
m_pos = 0;
m_lineNum = 1;
diff --git a/tools/scaninc/c_file.cpp b/tools/scaninc/c_file.cpp
index bb84fedbe..b82276dd6 100644
--- a/tools/scaninc/c_file.cpp
+++ b/tools/scaninc/c_file.cpp
@@ -24,24 +24,24 @@ CFile::CFile(std::string path)
{
m_path = path;
- FILE *fp = fopen(path.c_str(), "rb");
+ FILE *fp = std::fopen(path.c_str(), "rb");
if (fp == NULL)
FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
- fseek(fp, 0, SEEK_END);
+ std::fseek(fp, 0, SEEK_END);
- m_size = ftell(fp);
+ m_size = std::ftell(fp);
m_buffer = new char[m_size + 1];
m_buffer[m_size] = 0;
- rewind(fp);
+ std::rewind(fp);
- if (fread(m_buffer, m_size, 1, fp) != 1)
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
FATAL_ERROR("Failed to read \"%s\".\n", path.c_str());
- fclose(fp);
+ std::fclose(fp);
m_pos = 0;
m_lineNum = 1;
@@ -211,48 +211,6 @@ bool CFile::CheckIdentifier(const std::string& ident)
return (i == ident.length());
}
-std::unique_ptr<unsigned char[]> CFile::ReadWholeFile(const std::string& path, int& size)
-{
- FILE* fp = fopen(path.c_str(), "rb");
-
- if (fp == nullptr)
- FATAL_INPUT_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
-
- fseek(fp, 0, SEEK_END);
-
- size = ftell(fp);
-
- std::unique_ptr<unsigned char[]> buffer = std::unique_ptr<unsigned char[]>(new unsigned char[size]);
-
- rewind(fp);
-
- if (fread(buffer.get(), size, 1, fp) != 1)
- FATAL_INPUT_ERROR("Failed to read \"%s\".\n", path.c_str());
-
- fclose(fp);
-
- return buffer;
-}
-
-int ExtractData(const std::unique_ptr<unsigned char[]>& buffer, int offset, int size)
-{
- switch (size)
- {
- case 1:
- return buffer[offset];
- case 2:
- return (buffer[offset + 1] << 8)
- | buffer[offset];
- case 4:
- return (buffer[offset + 3] << 24)
- | (buffer[offset + 2] << 16)
- | (buffer[offset + 1] << 8)
- | buffer[offset];
- default:
- FATAL_ERROR("Invalid size passed to ExtractData.\n");
- }
-}
-
void CFile::CheckIncbin()
{
std::string idents[6] = { "INCBIN_S8", "INCBIN_U8", "INCBIN_S16", "INCBIN_U16", "INCBIN_S32", "INCBIN_U32" };
diff --git a/tools/scaninc/c_file.h b/tools/scaninc/c_file.h
index 2503acac1..922cb4639 100644
--- a/tools/scaninc/c_file.h
+++ b/tools/scaninc/c_file.h
@@ -46,7 +46,6 @@ private:
bool ConsumeHorizontalWhitespace();
bool ConsumeNewline();
void SkipWhitespace();
- std::unique_ptr<unsigned char[]> ReadWholeFile(const std::string& path, int& size);
bool CheckIdentifier(const std::string& ident);
void CheckIncbin();
};
diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp
index 2f9ed81e9..b6f7ba767 100644
--- a/tools/scaninc/scaninc.cpp
+++ b/tools/scaninc/scaninc.cpp
@@ -29,12 +29,12 @@
bool CanOpenFile(std::string path)
{
- FILE *fp = fopen(path.c_str(), "rb");
+ FILE *fp = std::fopen(path.c_str(), "rb");
if (fp == NULL)
return false;
- fclose(fp);
+ std::fclose(fp);
return true;
}
@@ -92,6 +92,6 @@ int main(int argc, char **argv)
for (const std::string &path : dependencies)
{
- printf("%s\n", path.c_str());
+ std::printf("%s\n", path.c_str());
}
}