[Scummvm-git-logs] scummvm master -> 820b226283f8d3b52cb71111ea116e795ff195ad

sev- noreply at scummvm.org
Sat May 21 07:50:32 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
820b226283 DEVTOOLS: Gather non-portable code in create_engine, thus making code more readable


Commit: 820b226283f8d3b52cb71111ea116e795ff195ad
    https://github.com/scummvm/scummvm/commit/820b226283f8d3b52cb71111ea116e795ff195ad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-05-21T09:49:43+02:00

Commit Message:
DEVTOOLS: Gather non-portable code in create_engine, thus making code more readable

Changed paths:
    devtools/create_engine/create_engine.cpp


diff --git a/devtools/create_engine/create_engine.cpp b/devtools/create_engine/create_engine.cpp
index 3757798baa9..714aaf844c7 100644
--- a/devtools/create_engine/create_engine.cpp
+++ b/devtools/create_engine/create_engine.cpp
@@ -47,7 +47,23 @@ static const char *const FILENAMES[] = {
 };
 const char *const ENGINES = "create_project ..\\.. --use-canonical-lib-names --msvc\n";
 
-// Replaces any occurances of the xyzzy placeholder with
+bool fileExists(const char *name) {
+#ifdef _MSC_VER
+	return (GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES);
+#else
+	return (!access(name, F_OK));
+#endif
+}
+
+bool createDirectory(const char *name) {
+#ifdef _MSC_VER
+	return CreateDirectoryA(name);
+#else
+	return (!mkdir(name, 0755));
+#endif
+}
+
+// Replaces any occurrences of the xyzzy placeholder with
 // whatever engine name was specified
 void replace_placeholders(char line[MAX_LINE_LENGTH]) {
 	char buf[MAX_LINE_LENGTH];
@@ -180,18 +196,10 @@ int main(int argc, char *argv[]) {
 
 	char prefix[100];
 	char prefix2[100];
-#ifdef _MSC_VER
-	if (GetFileAttributesA("../../engines") != INVALID_FILE_ATTRIBUTES) {
-#else
-	if (!access("../../engines", F_OK)) {
-#endif
+	if (fileExists("../../engines")) {
 		strcpy(prefix, "../..");
 		strcpy(prefix2, ".");
-#ifdef _MSC_VER
-	} else 	if (GetFileAttributesA("engines") != INVALID_FILE_ATTRIBUTES) {
-#else
-	} else if (!access("engines", F_OK)) {
-#endif
+	} else if (fileExists("engines")) {
 		strcpy(prefix, ".");
 		strcpy(prefix2, "devtools/create_engine");
 	} else {
@@ -207,11 +215,7 @@ int main(int argc, char *argv[]) {
 	printf("Creating directory %s...", folder);
 	fflush(stdout);
 
-#ifdef _MSC_VER
-	if (!CreateDirectoryA(folder, NULL)) {
-#else
-	if (mkdir(folder, 0755)) {
-#endif
+	if (!createDirectory(folder)) {
 		printf("Could not create engine folder.\n");
 		return 0;
 	}




More information about the Scummvm-git-logs mailing list