macOS 15.6, Apple Silicon
I'm trying to get RunProgram to run the following command (filename will vary) which works fine from Terminal (ie a JSON file is extracted and placed in /tmp)
Code: Select all
tar --zstd -xvf "/Users/xxxx/Desktop/vcv/v2/some file name.vcv" -C /tmp/ patch.json
ERROR: tar: Error opening archive: Can't initialize filter; unable to run program "zstd -d -qq"
Here is my code (apologies, I thought PB editor would convert tabs to spaces and this code is a mixture of new and copied from another of my projects which clearly has different tab settings):
Code: Select all
; given the path to a compressed VCV v2 file, uncompress it and get return the temp file path of
; the uncompressed JSON file
Procedure.s GetUncompressedFilePath(compressedFilePath.s, tempFileName.s = #DEFAULT_JSON_FILE_NAME)
Debug "_FileIndexing::GetDecompressedFilePath()"
Protected uncompressedPath.s = ""
Protected tempPath.s = GetTemporaryDirectory()
Protected cmd.s = "tar"
Protected params.s = "--zstd -xvf " + Chr(34) + compressedFilePath + Chr(34) + " -C " + tempPath + " " + tempFileName
uncompressedPath = tempPath + #DIR_SEPARATOR + tempFileName
; Clear existing file
If _FileSystem::FileExists(uncompressedPath)
DeleteFile(uncompressedPath)
EndIf
Protected error.s = ""
Protected programOutput.s = ""
Debug "Running terminal: " + cmd + " " + params
Protected shellProgram.i = RunProgram(cmd, params, "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Error)
If Not shellProgram
uncompressedPath = ""
Else
While ProgramRunning(shellProgram)
error = ReadProgramError(shellProgram)
If Not error = ""
uncompressedPath = ""
Debug "ERROR: " + error
Break
EndIf
If AvailableProgramOutput(shellProgram)
programOutput = ReadProgramString(shellProgram)
Debug " " + programOutput
EndIf
Wend
Debug "No more output from shell program"
CloseProgram(shellProgram)
EndIf
ExitProc:
ProcedureReturn uncompressedPath
EndProcedure
PS. ZStandard is installed via Homebrew
Code: Select all
xxx@xxx /tmp % which zstd
/opt/homebrew/bin/zstd
xxx@xxx /tmp % zstd --version
*** Zstandard CLI (64-bit) v1.5.7, by Yann Collet ***