GetChars in non-windows code.

This commit is contained in:
Christoph Oelckers 2023-10-08 08:12:18 +02:00
parent a2b93fdc23
commit 5919232fa7
9 changed files with 35 additions and 35 deletions

View file

@ -552,7 +552,7 @@ public:
return false;
}
File->Seek(-sizeof(header), FileReader::SeekCur);
File->Seek(-(ptrdiff_t)sizeof(header), FileReader::SeekCur);
FillBuffer();

View file

@ -348,7 +348,7 @@ extern bool AppActive;
for (size_t i = 0, count = s_argv.Size(); i < count; ++i)
{
if (0 == strcmp(s_argv[i], charFileName))
if (0 == strcmp(s_argv[i].GetChars(), charFileName))
{
return FALSE;
}

View file

@ -105,7 +105,7 @@ FString M_GetAppDataPath(bool create)
}
path += "/" GAMENAMELOWERCASE;
if (create) CreatePath(path);
if (create) CreatePath(path.GetChars());
return path;
}
@ -127,7 +127,7 @@ FString M_GetCachePath(bool create)
}
path += "/zdoom/cache";
if (create) CreatePath(path);
if (create) CreatePath(path.GetChars());
return path;
}
@ -169,9 +169,9 @@ FString M_GetConfigPath(bool for_reading)
{
// There seems to be no way to get Preferences path via NSFileManager
path += "/Preferences/";
CreatePath(path);
CreatePath(path.GetChars());
if (!DirExists(path))
if (!DirExists(path.GetChars()))
{
path = FString();
}
@ -200,7 +200,7 @@ FString M_GetScreenshotsPath()
{
path += "/" GAME_DIR "/Screenshots/";
}
CreatePath(path);
CreatePath(path.GetChars());
return path;
}
@ -241,7 +241,7 @@ FString M_GetDocumentsPath()
path += "/" GAME_DIR "/";
}
CreatePath(path);
CreatePath(path.GetChars());
return path;
}

View file

@ -86,13 +86,13 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
for(int i = 0;i < numwads;i++)
{
NSMutableDictionary *record = [[NSMutableDictionary alloc] initWithCapacity:NUM_COLUMNS];
const char* filename = strrchr(wads[i].Path, '/');
const char* filename = strrchr(wads[i].Path.GetChars(), '/');
if(filename == NULL)
filename = wads[i].Path;
filename = wads[i].Path.GetChars();
else
filename++;
[record setObject:[NSString stringWithUTF8String:filename] forKey:[NSString stringWithUTF8String:tableHeaders[COLUMN_IWAD]]];
[record setObject:[NSString stringWithUTF8String:wads[i].Name] forKey:[NSString stringWithUTF8String:tableHeaders[COLUMN_GAME]]];
[record setObject:[NSString stringWithUTF8String:wads[i].Name.GetChars()] forKey:[NSString stringWithUTF8String:tableHeaders[COLUMN_GAME]]];
[data addObject:record];
[record release];
}
@ -397,9 +397,9 @@ static void RestartWithParameters(const WadStuff& wad, NSString* parameters)
[arguments addObject:GetArchitectureString()];
[arguments addObject:executablePath];
[arguments addObject:@"-iwad"];
[arguments addObject:[NSString stringWithUTF8String:wad.Path]];
[arguments addObject:[NSString stringWithUTF8String:wad.Path.GetChars()]];
[arguments addObject:@"+defaultiwad"];
[arguments addObject:[NSString stringWithUTF8String:wad.Name]];
[arguments addObject:[NSString stringWithUTF8String:wad.Name.GetChars()]];
[arguments addObject:cvarArgument];
for (int i = 1, count = Args->NumArgs(); i < count; ++i)

View file

@ -118,7 +118,7 @@ void Unix_I_FatalError(const char* errortext)
FString cmd;
cmd << "kdialog --title \"" GAMENAME " " << GetVersionString()
<< "\" --msgbox \"" << errortext << "\"";
popen(cmd, "r");
popen(cmd.GetChars(), "r");
}
#ifndef NO_GTK
else if (I_GtkAvailable())
@ -131,7 +131,7 @@ void Unix_I_FatalError(const char* errortext)
FString title;
title << GAMENAME " " << GetVersionString();
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, errortext, NULL) < 0)
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title.GetChars(), errortext, NULL) < 0)
{
printf("\n%s\n", errortext);
}
@ -316,9 +316,9 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&
for(i = 0; i < numwads; ++i)
{
const char *filepart = strrchr(wads[i].Path, '/');
const char *filepart = strrchr(wads[i].Path.GetChars(), '/');
if(filepart == NULL)
filepart = wads[i].Path;
filepart = wads[i].Path.GetChars();
else
filepart++;
// Menu entries are specified in "tag" "item" pairs, where when a
@ -329,15 +329,15 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&
if(defaultiwad >= 0 && defaultiwad < numwads)
{
const char *filepart = strrchr(wads[defaultiwad].Path, '/');
const char *filepart = strrchr(wads[defaultiwad].Path.GetChars(), '/');
if(filepart == NULL)
filepart = wads[defaultiwad].Path;
filepart = wads[defaultiwad].Path.GetChars();
else
filepart++;
cmd.AppendFormat(" --default \"%s (%s)\"", wads[defaultiwad].Name.GetChars(), filepart);
}
FILE *f = popen(cmd, "r");
FILE *f = popen(cmd.GetChars(), "r");
if(f != NULL)
{
char gotstr[16];
@ -377,9 +377,9 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&
printf ("Please select a game wad (or 0 to exit):\n");
for (i = 0; i < numwads; ++i)
{
const char *filepart = strrchr (wads[i].Path, '/');
const char *filepart = strrchr (wads[i].Path.GetChars(), '/');
if (filepart == NULL)
filepart = wads[i].Path;
filepart = wads[i].Path.GetChars();
else
filepart++;
printf ("%d. %s (%s)\n", i+1, wads[i].Name.GetChars(), filepart);

View file

@ -139,7 +139,7 @@ namespace Priv
caption.Format(GAMENAME " %s (%s)", GetVersionString(), GetGitTime());
const uint32_t windowFlags = (win_maximized ? SDL_WINDOW_MAXIMIZED : 0) | SDL_WINDOW_RESIZABLE | extraFlags;
Priv::window = SDL_CreateWindow(caption,
Priv::window = SDL_CreateWindow(caption.GetChars(),
(win_x <= 0) ? SDL_WINDOWPOS_CENTERED_DISPLAY(vid_adapter) : win_x,
(win_y <= 0) ? SDL_WINDOWPOS_CENTERED_DISPLAY(vid_adapter) : win_y,
win_w, win_h, windowFlags);
@ -585,7 +585,7 @@ void I_SetWindowTitle(const char* caption)
{
FString default_caption;
default_caption.Format(GAMENAME " %s (%s)", GetVersionString(), GetGitTime());
SDL_SetWindowTitle(Priv::window, default_caption);
SDL_SetWindowTitle(Priv::window, default_caption.GetChars());
}
}

View file

@ -292,9 +292,9 @@ public:
store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
for (int i = 0; i < numwads; ++i)
{
const char *filepart = strrchr (wads[i].Path, '/');
const char *filepart = strrchr (wads[i].Path.GetChars(), '/');
if (filepart == NULL)
filepart = wads[i].Path;
filepart = wads[i].Path.GetChars();
else
filepart++;
gtk_list_store_append (store, &iter);

View file

@ -50,15 +50,15 @@ FString GetUserFile (const char *file)
path = NicePath("$HOME/" GAME_DIR "/");
if (stat (path, &info) == -1)
if (stat (path.GetChars(), &info) == -1)
{
struct stat extrainfo;
// Sanity check for $HOME/.config
FString configPath = NicePath("$HOME/.config/");
if (stat (configPath, &extrainfo) == -1)
if (stat (configPath.GetChars(), &extrainfo) == -1)
{
if (mkdir (configPath, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
if (mkdir (configPath.GetChars(), S_IRUSR | S_IWUSR | S_IXUSR) == -1)
{
I_FatalError ("Failed to create $HOME/.config directory:\n%s", strerror(errno));
}
@ -72,9 +72,9 @@ FString GetUserFile (const char *file)
// Transfer the old zdoom directory to the new location
bool moved = false;
FString oldpath = NicePath("$HOME/." GAMENAMELOWERCASE "/");
if (stat (oldpath, &extrainfo) != -1)
if (stat (oldpath.GetChars(), &extrainfo) != -1)
{
if (rename(oldpath, path) == -1)
if (rename(oldpath.GetChars(), path.GetChars()) == -1)
{
I_Error ("Failed to move old " GAMENAMELOWERCASE " directory (%s) to new location (%s).",
oldpath.GetChars(), path.GetChars());
@ -83,7 +83,7 @@ FString GetUserFile (const char *file)
moved = true;
}
if (!moved && mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
if (!moved && mkdir (path.GetChars(), S_IRUSR | S_IWUSR | S_IXUSR) == -1)
{
I_FatalError ("Failed to create %s directory:\n%s",
path.GetChars(), strerror (errno));
@ -115,7 +115,7 @@ FString M_GetAppDataPath(bool create)
FString path = NicePath("$HOME/.config/" GAMENAMELOWERCASE);
if (create)
{
CreatePath(path);
CreatePath(path.GetChars());
}
return path;
}
@ -135,7 +135,7 @@ FString M_GetCachePath(bool create)
FString path = NicePath("$HOME/.config/zdoom/cache");
if (create)
{
CreatePath(path);
CreatePath(path.GetChars());
}
return path;
}

View file

@ -905,7 +905,7 @@ FString NicePath(const char *path)
slash = path + strlen(path);
}
FString who(path, slash - path);
pwstruct = getpwnam(who);
pwstruct = getpwnam(who.GetChars());
}
if (pwstruct == NULL)
{