Create icon.rc file on all platforms, copy ico file into temp
Previously, the creation of the icon.rc file was restricted to be
Windows only because Windows is the only platform with a use for that
file. Unfortunately, this breaks a fundimental assumption about how the
QB64 C++ generation works, because we only have one set of
`./internal/source` files from which we build all versions of QB64 for
all platforms. Due to that, the built version needs to include all files
needed by all platforms, regardless of which one is doing the building.
So to that end, all platforms should produce the icon.rc, even if it
will not be used on that platform.
Additionally, the path to the icon file in `icon.rc` is problimatic
because it is made into an absolute path. This blocks `qb64.bas` from
using `$EXEICON` because the absolute path is not predictable, as
the location we create ./internal/source will be different from the
location we build ./internal/source. Effectively this means that the
`icon.rc` file in `./internal/source` would always be wrong.
The solution is to not use an absolute path, with the other option being
to have the icon in the same directory as the resource file. This is
actually relatively easy to acomplish since icon files are not terribly
large and we can simply copy it into the temp directory.
Thus, that is what this change does - the specified icon file is copied
into the temp directory as `icon.ico`, which allows use to use
`icon.ico` in the `icon.rc` file and have it always work regardless of
directory.
The internal logic was also cleaned up a bit. The creation of these
files is no longer Windows specific, and the $EXEICON parsing no longer
writes to the `icon.rc` file - rather, the entire thing is generated
together, with both the $VERSIONINFo and $EXEICON depending on which
were provided.
2022-05-01 02:33:43 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
' Duplicates the contents of one file into another
|
|
|
|
'
|
|
|
|
' Returns: 0 on success, 1 on error
|
|
|
|
FUNCTION CopyFile& (sourceFile$, destFile$)
|
|
|
|
DIM sourcefileNo, destFileNo
|
|
|
|
DIM fileLength AS _INTEGER64
|
|
|
|
|
|
|
|
E = 0
|
|
|
|
sourceFileNo = FREEFILE
|
|
|
|
OPEN sourceFile$ FOR BINARY as #sourceFileNo
|
|
|
|
if E = 1 THEN GOTO errorCleanup
|
|
|
|
|
|
|
|
fileLength = LOF(sourceFileNo)
|
|
|
|
|
|
|
|
destFileNo = FREEFILE
|
|
|
|
OPEN destFile$ FOR BINARY as #destFileNo
|
|
|
|
if E = 1 THEN GOTO errorCleanup
|
|
|
|
|
|
|
|
' Read the file in one go
|
|
|
|
buffer$ = SPACE$(fileLength)
|
|
|
|
|
|
|
|
GET #sourceFileNo, , buffer$
|
|
|
|
PUT #destFileNo, , buffer$
|
|
|
|
|
|
|
|
errorCleanup:
|
|
|
|
IF sourceFileNo <> 0 THEN CLOSE #sourceFileNo
|
|
|
|
IF destFileNo <> 0 THEN CLOSE #destFileNo
|
|
|
|
|
|
|
|
CopyFile& = E
|
|
|
|
END FUNCTION
|
2022-05-06 03:17:02 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
' Splits the filename from its path, and returns the path
|
|
|
|
'
|
|
|
|
' Returns: The path, or empty if no path
|
|
|
|
FUNCTION getfilepath$ (f$)
|
|
|
|
FOR i = LEN(f$) TO 1 STEP -1
|
|
|
|
a$ = MID$(f$, i, 1)
|
|
|
|
IF a$ = "/" OR a$ = "\" THEN
|
|
|
|
getfilepath$ = LEFT$(f$, i)
|
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
|
|
|
NEXT
|
|
|
|
getfilepath$ = ""
|
|
|
|
END FUNCTION
|
|
|
|
|
|
|
|
'
|
|
|
|
' Checks if a filename has an extension on the end
|
|
|
|
'
|
|
|
|
' Returns: True if provided filename has an extension
|
|
|
|
FUNCTION FileHasExtension (f$)
|
|
|
|
FOR i = LEN(f$) TO 1 STEP -1
|
|
|
|
a = ASC(f$, i)
|
|
|
|
IF a = 47 OR a = 92 THEN EXIT FOR
|
|
|
|
IF a = 46 THEN FileHasExtension = -1: EXIT FUNCTION
|
|
|
|
NEXT
|
|
|
|
END FUNCTION
|
|
|
|
|
|
|
|
'
|
|
|
|
' Strips the extension off of a filename
|
|
|
|
'
|
|
|
|
' Returns: Provided filename without extension on the end
|
|
|
|
FUNCTION RemoveFileExtension$ (f$)
|
|
|
|
FOR i = LEN(f$) TO 1 STEP -1
|
|
|
|
a = ASC(f$, i)
|
|
|
|
IF a = 47 OR a = 92 THEN EXIT FOR
|
|
|
|
IF a = 46 THEN RemoveFileExtension$ = LEFT$(f$, i - 1): EXIT FUNCTION
|
|
|
|
NEXT
|
|
|
|
RemoveFileExtension$ = f$
|
|
|
|
END FUNCTION
|
|
|
|
|
|
|
|
'
|
|
|
|
' Fixes the provided filename and path to use the correct path separator
|
|
|
|
'
|
|
|
|
SUB PATH_SLASH_CORRECT (a$)
|
|
|
|
IF os$ = "WIN" THEN
|
|
|
|
FOR x = 1 TO LEN(a$)
|
|
|
|
IF ASC(a$, x) = 47 THEN ASC(a$, x) = 92
|
|
|
|
NEXT
|
|
|
|
ELSE
|
|
|
|
FOR x = 1 TO LEN(a$)
|
|
|
|
IF ASC(a$, x) = 92 THEN ASC(a$, x) = 47
|
|
|
|
NEXT
|
|
|
|
END IF
|
|
|
|
END SUB
|