From 972687de7206022b01175405c104412a47a573ea Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 1 Apr 2023 16:10:45 -0700 Subject: [PATCH] Fix Luigi sounds compilation issues (you must run make clean in the tools folder before you see the changes) --- tools/aiff_extract_codebook_failsafe.py | 27 ++++++++++++++++++++----- tools/audiofile/audiofile.cpp | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/aiff_extract_codebook_failsafe.py b/tools/aiff_extract_codebook_failsafe.py index 0b9f885e..3d0db14b 100644 --- a/tools/aiff_extract_codebook_failsafe.py +++ b/tools/aiff_extract_codebook_failsafe.py @@ -1,10 +1,12 @@ #!/usr/bin/env python3 import sys import os +import time import subprocess # example before: tools/aiff_extract_codebook sound/samples/sfx_custom_luigi/00.aiff >build/us_pc/sound/samples/sfx_custom_luigi/00.table + s_size = 0 # check arguments @@ -25,14 +27,29 @@ else: s_cmd = [ a_cmd, a_input ] with open(a_output, 'w') as outfile: subprocess.call(s_cmd, stdout=outfile, shell=False) + outfile.flush() + os.fsync(outfile.fileno()) - # get size + # try to read the file length repeatedly + s_itr = 0 + while s_size <= 0 and s_itr < 8: + # sleep between iterations + if s_itr > 0: + time.sleep(0.1 + 0.05 * s_itr) + s_itr += 1 + + # check for existence + if not os.path.isfile(a_output): + continue + + # read file size + with open(a_output, 'r') as outfile: + s_text = outfile.read() + s_size = len(s_text) + + # check final existence if not os.path.isfile(a_output): print(sys.argv[0] + ': original output file does not exist "' + a_output + '"', file=sys.stderr) - else: - with open(a_output, 'r') as outfile: - s_text = outfile.read().strip() - s_size = len(s_text) # check size if s_size > 6: diff --git a/tools/audiofile/audiofile.cpp b/tools/audiofile/audiofile.cpp index 7cd78946..4312c02d 100644 --- a/tools/audiofile/audiofile.cpp +++ b/tools/audiofile/audiofile.cpp @@ -8243,7 +8243,7 @@ File *File::open(const char *path, File::AccessMode mode) flags = O_RDONLY; else if (mode == WriteAccess) flags = O_CREAT | O_WRONLY | O_TRUNC; -#if defined(WIN32) || defined(__CYGWIN__) +#if defined(WIN32) || defined(__CYGWIN__) || defined(_WIN32) flags |= O_BINARY; #endif int fd = ::open(path, flags, 0666);