Skip to content

Commit

Permalink
.grooming extra .string() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ped7g committed Jan 16, 2025
1 parent 263ecdd commit 852255b
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 51 deletions.
18 changes: 9 additions & 9 deletions sjasm/directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ static void dirINCBIN() {
length = val;
}
}
BinIncFile(fnaam.string().c_str(), offset, length, system_paths_first); //FIXME path idea ready with refactoring
BinIncFile(fnaam.c_str(), offset, length, system_paths_first); //FIXME path idea ready with refactoring
}

static void dirINCHOB() {
Expand Down Expand Up @@ -613,20 +613,20 @@ static void dirINCHOB() {
}
}

fnaamh = GetPath(fnaam.string().c_str(), nullptr, system_paths_first); //FIXME path idea ready
fnaamh = GetPath(fnaam.c_str(), nullptr, system_paths_first); //FIXME path idea ready
if (!FOPEN_ISOK(ff, fnaamh, "rb")) {
Error("[INCHOB] Error opening file", fnaam.string().c_str(), FATAL);
Error("[INCHOB] Error opening file", fnaam.c_str(), FATAL);
}
if (fseek(ff, 0x0b, 0) || 2 != fread(len, 1, 2, ff)) {
Error("[INCHOB] Hobeta file has wrong format", fnaam.string().c_str(), FATAL);
Error("[INCHOB] Hobeta file has wrong format", fnaam.c_str(), FATAL);
}
fclose(ff);
if (length == -1) {
// calculate remaining length of the file (from the specified offset)
length = len[0] + (len[1] << 8) - offset;
}
offset += 17; // adjust offset (skip HOB header)
BinIncFile(fnaam.string().c_str(), offset, length, system_paths_first); //FIXME path idea ready w/ refactoring
BinIncFile(fnaam.c_str(), offset, length, system_paths_first); //FIXME path idea ready w/ refactoring
free(fnaamh);
}

Expand Down Expand Up @@ -670,8 +670,8 @@ static void dirINCTRD() {
length = val;
}
}
if (TRD_PrepareIncFile(trdname.string().c_str(), filename.c_str(), offset, length, system_paths_first)) { //FIXME path idea ready w/ refactoring^2
BinIncFile(trdname.string().c_str(), offset, length, system_paths_first); //FIXME path idea ready w/ refactoring
if (TRD_PrepareIncFile(trdname.c_str(), filename.c_str(), offset, length, system_paths_first)) { //FIXME path idea ready w/ refactoring^2
BinIncFile(trdname.c_str(), offset, length, system_paths_first); //FIXME path idea ready w/ refactoring
}
}

Expand Down Expand Up @@ -1483,7 +1483,7 @@ static void dirINCLUDE() {
if (fnaam.has_filename()) {
EDelimiterType dt = GetDelimiterOfLastFileName();
ListFile();
IncludeFile(fnaam.string().c_str(), DT_ANGLE == dt); //FIXME path idea possible with refactoring^2
IncludeFile(fnaam.c_str(), DT_ANGLE == dt); //FIXME path idea possible with refactoring^2
donotlist = 1;
} else {
Error("[INCLUDE] empty filename", bp);
Expand Down Expand Up @@ -1590,7 +1590,7 @@ static void dirEXPORT() {
assert(!sourcePosStack.empty());
Options::ExportFName = sourcePosStack.back().filename;
Options::ExportFName.replace_extension(".exp");
Warning("[EXPORT] Filename for exportfile was not indicated. Output will be in", Options::ExportFName.string().c_str(), W_EARLY);
Warning("[EXPORT] Filename for exportfile was not indicated. Output will be in", Options::ExportFName.c_str(), W_EARLY);
}
if (!(n = p = GetID(lp))) {
Error("[EXPORT] Syntax error", lp, SUPPRESS);
Expand Down
6 changes: 3 additions & 3 deletions sjasm/io_cpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace
{
// report error and close the file
static int writeError(const std::filesystem::path & fname, FILE*& fileToClose) {
Error("[SAVECPCSNA] Write error (disk full?)", fname.string().c_str(), IF_FIRST);
Error("[SAVECPCSNA] Write error (disk full?)", fname.c_str(), IF_FIRST);
fclose(fileToClose);
return 0;
}
Expand All @@ -62,7 +62,7 @@ static int SaveSNA_CPC(const std::filesystem::path & fname, word start) {

FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) {
Error("[SAVECPCSNA] Error opening file for write", fname.string().c_str());
Error("[SAVECPCSNA] Error opening file for write", fname.c_str());
return 0;
}

Expand Down Expand Up @@ -785,7 +785,7 @@ void dirSAVECDT() {
static int SaveCPR(const std::filesystem::path & fname, int cprSize) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) {
Error("[SAVECPR] Error opening file for write", fname.string().c_str());
Error("[SAVECPR] Error opening file for write", fname.c_str());
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions sjasm/io_nex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void SBmpFile::close() {

bool SBmpFile::open(const std::filesystem::path & bmpname) {
if (!FOPEN_ISOK(bmp, bmpname, "rb")) {
Error("[SAVENEX] Error opening file", bmpname.string().c_str(), SUPPRESS);
Error("[SAVENEX] Error opening file", bmpname.c_str(), SUPPRESS);
return false;
}
palBuffer = new byte[4*PALETTE_SIZE];
Expand All @@ -324,7 +324,7 @@ bool SBmpFile::open(const std::filesystem::path & bmpname) {
40 != header2Size || 1 != colorPlanes || 8 != bpp || 0 != compressionType)
{
Error("[SAVENEX] BMP file is not in expected format (uncompressed, 8bpp, 40B BITMAPINFOHEADER header)",
bmpname.string().c_str(), SUPPRESS);
bmpname.c_str(), SUPPRESS);
close();
return false;
}
Expand Down Expand Up @@ -438,7 +438,7 @@ static void dirNexOpen() {
return;
}
// try to open the actual file
if (!FOPEN_ISOK(nex.f, fname, "w+b")) Error("[SAVENEX] Error opening file for write", fname.string().c_str(), SUPPRESS);
if (!FOPEN_ISOK(nex.f, fname, "w+b")) Error("[SAVENEX] Error opening file for write", fname.c_str(), SUPPRESS);
if (nullptr == nex.f) return;
// set the argument values into header, and write the initial version of header into file
nex.h.pc = openArgs[0] & 0xFFFF;
Expand Down Expand Up @@ -753,7 +753,7 @@ static void dirNexScreenBmp() {
SBmpFile bmp;
bool bmpOpened = bmp.open(bmpname);
if (bmpOpened && other == bmp.type) {
Error("[SAVENEX] BMP file is not 256x192, 128x96, 320x256 or 640x256", bmpname.string().c_str(), SUPPRESS);
Error("[SAVENEX] BMP file is not 256x192, 128x96, 320x256 or 640x256", bmpname.c_str(), SUPPRESS);
bmpOpened = false;
}
if (!bmpOpened) return;
Expand Down Expand Up @@ -1043,7 +1043,7 @@ static void dirNexClose() {
if (appendName.has_filename()) { // some append file requested, try to copy its content at tail of NEX
FILE* appendF = nullptr;
if (!FOPEN_ISOK(appendF, appendName, "rb")) {
Error("[SAVENEX] Error opening append file", appendName.string().c_str(), SUPPRESS);
Error("[SAVENEX] Error opening append file", appendName.c_str(), SUPPRESS);
} else {
static constexpr int copyBufSize = 0x4000;
byte* copyBuffer = new byte[copyBufSize];
Expand Down
6 changes: 3 additions & 3 deletions sjasm/io_snapshots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// report error and close the file
static bool writeError(const std::filesystem::path & fname, FILE* & fileToClose) {
Error("Write error (disk full?)", fname.string().c_str(), IF_FIRST);
Error("Write error (disk full?)", fname.c_str(), IF_FIRST);
fclose(fileToClose);
return false;
}
Expand All @@ -47,7 +47,7 @@ bool SaveSNA_ZX(const std::filesystem::path & fname, word start) {

FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) {
Error("opening file for write", fname.string().c_str());
Error("opening file for write", fname.c_str());
return false;
}

Expand Down Expand Up @@ -139,7 +139,7 @@ bool SaveSNA_ZX(const std::filesystem::path & fname, word start) {
}

if (128*1024 < Device->PagesCount * Device->GetPage(0)->Size) {
WarningById(W_SNA_128, fname.string().c_str());
WarningById(W_SNA_128, fname.c_str());
}

fclose(ff);
Expand Down
6 changes: 3 additions & 3 deletions sjasm/io_tape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static aint detect_ram_start(unsigned char* ram, aint length);
int TAP_SaveEmpty(const std::filesystem::path & fname) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) {
Error("opening file for write", fname.string().c_str()); return 0;
Error("opening file for write", fname.c_str()); return 0;
}
fclose(ff);
return 1;
Expand All @@ -54,7 +54,7 @@ int TAP_SaveEmpty(const std::filesystem::path & fname) {
int TAP_SaveBlock(const std::filesystem::path & fname, unsigned char flag, const char *ftapname, int start, int length, int param2, int param3) {
FILE* fpout;
if (!FOPEN_ISOK(fpout, fname, "ab")) {
Error("opening file for append", fname.string().c_str(), FATAL);
Error("opening file for append", fname.c_str(), FATAL);
}

if (length + start > 0x10000) {
Expand Down Expand Up @@ -136,7 +136,7 @@ int TAP_SaveBlock(const std::filesystem::path & fname, unsigned char flag, const
int TAP_SaveSnapshot(const std::filesystem::path & fname, unsigned short start) {
FILE* fpout;
if (!FOPEN_ISOK(fpout, fname, "wb")) {
Error("opening file for write", fname.string().c_str(), FATAL);
Error("opening file for write", fname.c_str(), FATAL);
}

aint datastart = 0x5E00;
Expand Down
10 changes: 5 additions & 5 deletions sjasm/io_trd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ static int saveEmptyWrite(FILE* ff, byte* buf, const char label[8]) {
bool TRD_SaveEmpty(const std::filesystem::path & fname, const char label[8]) {
FILE* ff;
if (!fname.has_filename() || !FOPEN_ISOK(ff, fname, "wb")) {
Error("opening file for write", fname.string().c_str(), IF_FIRST);
Error("opening file for write", fname.c_str(), IF_FIRST);
return 0;
}
byte* buf = (byte*) calloc(STrdDisc::SECTORS_PER_TRACK*STrdDisc::SECTOR_SZ, sizeof(byte));
if (buf == NULL) ErrorOOM();
int result = saveEmptyWrite(ff, buf, label);
free(buf);
fclose(ff);
if (!result) Error("Write error (disk full?)", fname.string().c_str(), IF_FIRST);
if (!result) Error("Write error (disk full?)", fname.c_str(), IF_FIRST);
return result;
}

Expand Down Expand Up @@ -226,7 +226,7 @@ ETrdFileName TRD_FileNameToBytes(const char* inputName, byte binName[12], int &

static int ReturnWithError(const char* errorText, const std::filesystem::path & fname, FILE* fileToClose) {
if (nullptr != fileToClose) fclose(fileToClose);
Error(errorText, fname.string().c_str(), IF_FIRST);
Error(errorText, fname.c_str(), IF_FIRST);
return 0;
}

Expand Down Expand Up @@ -366,7 +366,7 @@ bool TRD_AddFile(const std::filesystem::path & fname, const char* fhobname, int
if (STrdHead::NUM_OF_FILES_MAX != fileIndex) {
// to keep legacy behaviour of older sjasmplus versions, this is just warning
// and the same file will be added to end of directory any way
WarningById(W_TRD_DUPLICATE, fname.string().c_str());
WarningById(W_TRD_DUPLICATE, fname.c_str());
}
fileIndex = trdHead.info.numOfFiles;
}
Expand Down Expand Up @@ -493,7 +493,7 @@ int TRD_PrepareIncFile(const std::filesystem::path & trdname, const char* filena

// read 9 sectors of disk into "trdHead" (contains root directory catalog and disk info data)
STrdHead trdHead;
char* fullTrdName = GetPath(trdname.string().c_str(), nullptr, systemPathsFirst); //FIXME path idea ready with refactoring^2
char* fullTrdName = GetPath(trdname.c_str(), nullptr, systemPathsFirst); //FIXME path idea ready with refactoring^2
FILE* ff = SJ_fopen(fullTrdName, "rb");
free(fullTrdName);
fullTrdName = nullptr;
Expand Down
8 changes: 4 additions & 4 deletions sjasm/io_tzx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace TZXBlockId {
void TZX_CreateEmpty(const std::filesystem::path & fname) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) {
Error("[TZX] Error opening file for write", fname.string().c_str(), FATAL);
Error("[TZX] Error opening file for write", fname.c_str(), FATAL);
}

constexpr byte tzx_major_version = 1;
Expand All @@ -54,7 +54,7 @@ void TZX_AppendPauseBlock(const std::filesystem::path & fname, uint16_t pauseAft
{
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "a+b")) {
Error("[TZX] Error opening file for append", fname.string().c_str(), FATAL);
Error("[TZX] Error opening file for append", fname.c_str(), FATAL);
}
fputc(TZXBlockId::Pause, ff); // block id

Expand All @@ -67,7 +67,7 @@ void TZX_AppendStandardBlock(const std::filesystem::path & fname,
const byte* buf, const aint buflen, word pauseAfterMs, byte sync) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "a+b")) {
Error("[TZX] Error opening file for append", fname.string().c_str(), FATAL);
Error("[TZX] Error opening file for append", fname.c_str(), FATAL);
}

const aint totalDataLen = buflen + 2; // + sync byte + checksum
Expand All @@ -91,7 +91,7 @@ void TZX_AppendTurboBlock(const std::filesystem::path & fname,
const byte* buf, const aint buflen, const STZXTurboBlock& turbo) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "a+b")) {
Error("[TZX] Error opening file for append", fname.string().c_str(), FATAL);
Error("[TZX] Error opening file for append", fname.c_str(), FATAL);
}

fputc(TZXBlockId::Turbo, ff); // block id
Expand Down
28 changes: 14 additions & 14 deletions sjasm/sjio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ static void OpenListImp(const std::filesystem::path & listFilename) {
if (OV_LST == Options::OutputVerbosity) return;
if (listFilename.empty()) return;
if (!FOPEN_ISOK(FP_ListingFile, listFilename, "w")) {
Error("opening file for write", listFilename.string().c_str(), FATAL);
Error("opening file for write", listFilename.c_str(), FATAL);
}
}

Expand Down Expand Up @@ -891,7 +891,7 @@ void OpenDest(int mode) {
mode = OUTPUT_TRUNCATE;
}
if (!Options::NoDestinationFile && !FOPEN_ISOK(FP_Output, Options::DestinationFName, mode == OUTPUT_TRUNCATE ? "wb" : "r+b")) {
Error("opening file for write", Options::DestinationFName.string().c_str(), FATAL);
Error("opening file for write", Options::DestinationFName.c_str(), FATAL);
}
Options::NoDestinationFile = false;
if (NULL == FP_RAW && "-" == Options::RAWFName) {
Expand All @@ -900,7 +900,7 @@ void OpenDest(int mode) {
switchStdOutIntoBinaryMode();
}
if (FP_RAW == NULL && Options::RAWFName.has_filename() && !FOPEN_ISOK(FP_RAW, Options::RAWFName, "wb")) {
Error("opening file for write", Options::RAWFName.string().c_str());
Error("opening file for write", Options::RAWFName.c_str());
}
if (FP_Output != NULL && mode != OUTPUT_TRUNCATE) {
if (fseek(FP_Output, 0, mode == OUTPUT_REWIND ? SEEK_SET : SEEK_END)) {
Expand Down Expand Up @@ -934,10 +934,10 @@ void OpenTapFile(const std::filesystem::path & tapename, int flagbyte)
CloseTapFile();

if (!FOPEN_ISOK(FP_tapout,tapename, "r+b")) {
Error( "opening file for write", tapename.string().c_str());
Error( "opening file for write", tapename.c_str());
return;
}
if (fseek(FP_tapout, 0, SEEK_END)) Error("File seek end error in TAPOUT", tapename.string().c_str(), FATAL);
if (fseek(FP_tapout, 0, SEEK_END)) Error("File seek end error in TAPOUT", tapename.c_str(), FATAL);

tape_seek = ftell(FP_tapout);
tape_parity = flagbyte;
Expand Down Expand Up @@ -1042,7 +1042,7 @@ unsigned char MemGetByte(unsigned int address) {

int SaveBinary(const std::filesystem::path & fname, aint start, aint length) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.string().c_str(), FATAL);
if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.c_str(), FATAL);
int result = SaveRAM(ff, start, length);
fclose(ff);
return result;
Expand All @@ -1051,7 +1051,7 @@ int SaveBinary(const std::filesystem::path & fname, aint start, aint length) {

int SaveBinary3dos(const std::filesystem::path & fname, aint start, aint length, byte type, word w2, word w3) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.string().c_str(), FATAL);
if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.c_str(), FATAL);
// prepare +3DOS 128 byte header content
constexpr aint hsize = 128;
const aint full_length = hsize + length;
Expand Down Expand Up @@ -1081,7 +1081,7 @@ int SaveBinary3dos(const std::filesystem::path & fname, aint start, aint length,
int SaveBinaryAmsdos(const std::filesystem::path & fname, aint start, aint length, word start_adr, byte type) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) {
Error("opening file for write", fname.string().c_str(), SUPPRESS);
Error("opening file for write", fname.c_str(), SUPPRESS);
return 0;
}
// prepare AMSDOS 128 byte header content
Expand Down Expand Up @@ -1115,7 +1115,7 @@ bool SaveDeviceMemory(FILE* file, const size_t start, const size_t length) {
// start and length must be sanitized by caller
bool SaveDeviceMemory(const std::filesystem::path & fname, const size_t start, const size_t length) {
FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.string().c_str(), FATAL);
if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.c_str(), FATAL);
bool res = SaveDeviceMemory(ff, start, length);
fclose(ff);
return res;
Expand Down Expand Up @@ -1172,7 +1172,7 @@ int SaveHobeta(const std::filesystem::path & fname, const char* fhobname, aint s

FILE* ff;
if (!FOPEN_ISOK(ff, fname, "wb")) {
Error("opening file for write", fname.string().c_str(), FATAL);
Error("opening file for write", fname.c_str(), FATAL);
}

int result = (17 == fwrite(header, 1, 17, ff)) && SaveRAM(ff, start, length);
Expand Down Expand Up @@ -1305,7 +1305,7 @@ void OpenExpFile() {
assert(nullptr == FP_ExportFile); // this should be the first and only call to open it
if (!Options::ExportFName.has_filename()) return; // no export file name provided, skip opening
if (FOPEN_ISOK(FP_ExportFile, Options::ExportFName, "w")) return;
Error("opening file for write", Options::ExportFName.string().c_str(), ALL);
Error("opening file for write", Options::ExportFName.c_str(), ALL);
}

void WriteLabelEquValue(const char* name, aint value, FILE* f) {
Expand Down Expand Up @@ -1342,7 +1342,7 @@ static void WriteToSldFile_TextFilePos(char* buffer, const TextFilePos & pos) {
static void OpenSldImp(const std::filesystem::path & sldFilename) {
if (!sldFilename.has_filename()) return;
if (!FOPEN_ISOK(FP_SourceLevelDebugging, sldFilename, "w")) {
Error("opening file for write", sldFilename.string().c_str(), FATAL);
Error("opening file for write", sldFilename.c_str(), FATAL);
}
fputs("|SLD.data.version|1\n", FP_SourceLevelDebugging);
if (0 < sldCommentKeywords.size()) {
Expand Down Expand Up @@ -1476,15 +1476,15 @@ static int breakpointsCounter;

void OpenBreakpointsFile(const std::filesystem::path & filename, const EBreakpointsFile type) {
if (!filename.has_filename()) {
Error("empty filename", filename.string().c_str(), EARLY);
Error("empty filename", filename.c_str(), EARLY);
return;
}
if (FP_BreakpointsFile) {
Error("breakpoints file was already opened", nullptr, EARLY);
return;
}
if (!FOPEN_ISOK(FP_BreakpointsFile, filename, "w")) {
Error("opening file for write", filename.string().c_str(), EARLY);
Error("opening file for write", filename.c_str(), EARLY);
}
breakpointsCounter = 0;
breakpointsType = type;
Expand Down
Loading

0 comments on commit 852255b

Please sign in to comment.