mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-08 07:09:18 -05:00
Compare commits
5 Commits
d6f9988e82
...
60826855c4
| Author | SHA1 | Date | |
|---|---|---|---|
| 60826855c4 | |||
| 5daeffd91b | |||
| e11bf1c978 | |||
| c6241b91a2 | |||
| f73b04c42c |
3
.github/workflows/parse.yml
vendored
3
.github/workflows/parse.yml
vendored
@ -32,6 +32,7 @@ jobs:
|
|||||||
set -x
|
set -x
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git add parser
|
git add tools/parser
|
||||||
git commit -m "Update raylib_api.* by CI"
|
git commit -m "Update raylib_api.* by CI"
|
||||||
git push
|
git push
|
||||||
|
|
||||||
|
|||||||
@ -1129,7 +1129,7 @@ RLAPI bool SaveFileText(const char *fileName, const char *text); // Save text d
|
|||||||
// File system functions
|
// File system functions
|
||||||
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
||||||
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
|
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
|
||||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (including point: .png, .wav)
|
RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (recommended include point: .png, .wav)
|
||||||
RLAPI int GetFileLength(const char *fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
|
RLAPI int GetFileLength(const char *fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
|
||||||
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')
|
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')
|
||||||
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
|
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
|
||||||
|
|||||||
51
src/rcore.c
51
src/rcore.c
@ -113,7 +113,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h> // Required for: srand(), rand(), atexit()
|
#include <stdlib.h> // Required for: srand(), rand(), atexit()
|
||||||
#include <stdio.h> // Required for: sprintf() [Used in OpenURL()]
|
#include <stdio.h> // Required for: sprintf() [Used in OpenURL()]
|
||||||
#include <string.h> // Required for: strrchr(), strcmp(), strlen(), memset()
|
#include <string.h> // Required for: strlen(), strcpy(), strcmp(), strrchr(), memset()
|
||||||
#include <time.h> // Required for: time() [Used in InitTimer()]
|
#include <time.h> // Required for: time() [Used in InitTimer()]
|
||||||
#include <math.h> // Required for: tan() [Used in BeginMode3D()], atan2f() [Used in LoadVrStereoConfig()]
|
#include <math.h> // Required for: tan() [Used in BeginMode3D()], atan2f() [Used in LoadVrStereoConfig()]
|
||||||
|
|
||||||
@ -1940,34 +1940,61 @@ bool FileExists(const char *fileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check file extension
|
// Check file extension
|
||||||
// TODO: Avoid [rtext] module dependency
|
|
||||||
bool IsFileExtension(const char *fileName, const char *ext)
|
bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
{
|
{
|
||||||
#define MAX_FILE_EXTENSION_LENGTH 16
|
#define MAX_FILE_EXTENSIONS 32
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
const char *fileExt = GetFileExtension(fileName);
|
const char *fileExt = GetFileExtension(fileName);
|
||||||
|
|
||||||
if (fileExt != NULL)
|
if (fileExt != NULL)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_TEXT_MANIPULATION)
|
int fileExtLen = strlen(fileExt);
|
||||||
int extCount = 0;
|
char fileExtLower[8] = { 0 };
|
||||||
char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext
|
char *fileExtLowerPtr = fileExtLower;
|
||||||
|
for (int i = 0; i < fileExtLen; i++)
|
||||||
|
{
|
||||||
|
// Copy and convert to lower-case
|
||||||
|
if ((fileExt[i] >= 'A') && (fileExt[i] <= 'Z')) fileExtLower[i] = fileExt[i] + 32;
|
||||||
|
else fileExtLower[i] = fileExt[i];
|
||||||
|
}
|
||||||
|
|
||||||
char fileExtLower[MAX_FILE_EXTENSION_LENGTH + 1] = { 0 };
|
int extCount = 1;
|
||||||
strncpy(fileExtLower, TextToLower(fileExt), MAX_FILE_EXTENSION_LENGTH); // WARNING: Module required: rtext
|
int extLen = strlen(ext);
|
||||||
|
char *extList = (char *)RL_CALLOC(extLen + 1, 1);
|
||||||
|
char *extListPtrs[MAX_FILE_EXTENSIONS] = { 0 };
|
||||||
|
strcpy(extList, ext);
|
||||||
|
extListPtrs[0] = extList;
|
||||||
|
|
||||||
|
for (int i = 0; i < extLen; i++)
|
||||||
|
{
|
||||||
|
// Convert to lower-case if extension is upper-case
|
||||||
|
if ((extList[i] >= 'A') && (extList[i] <= 'Z')) extList[i] += 32;
|
||||||
|
|
||||||
|
// Get pointer to next extension and add null-terminator
|
||||||
|
if ((extList[i] == ';') && (extCount < (MAX_FILE_EXTENSIONS - 1)))
|
||||||
|
{
|
||||||
|
extList[i] = '\0';
|
||||||
|
extListPtrs[extCount] = extList + i + 1;
|
||||||
|
extCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < extCount; i++)
|
for (int i = 0; i < extCount; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(fileExtLower, TextToLower(checkExts[i])) == 0)
|
// Consider the case where extension provided
|
||||||
|
// does not start with the '.'
|
||||||
|
fileExtLowerPtr = fileExtLower;
|
||||||
|
if (extListPtrs[i][0] != '.') fileExtLowerPtr++;
|
||||||
|
|
||||||
|
if (strcmp(fileExtLowerPtr, extListPtrs[i]) == 0)
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (strcmp(fileExt, ext) == 0) result = true;
|
RL_FREE(extList);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ FORMAT?=DEFAULT
|
|||||||
raylib_parser: raylib_parser.c
|
raylib_parser: raylib_parser.c
|
||||||
cc raylib_parser.c -o raylib_parser
|
cc raylib_parser.c -o raylib_parser
|
||||||
|
|
||||||
raylib_api: ../src/raylib.h raylib_parser
|
raylib_api: ../../src/raylib.h raylib_parser
|
||||||
FORMAT=DEFAULT EXTENSION=txt $(MAKE) raylib_api.txt
|
FORMAT=DEFAULT EXTENSION=txt $(MAKE) raylib_api.txt
|
||||||
FORMAT=JSON EXTENSION=json $(MAKE) raylib_api.json
|
FORMAT=JSON EXTENSION=json $(MAKE) raylib_api.json
|
||||||
FORMAT=XML EXTENSION=xml $(MAKE) raylib_api.xml
|
FORMAT=XML EXTENSION=xml $(MAKE) raylib_api.xml
|
||||||
|
|||||||
@ -4438,7 +4438,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "IsFileExtension",
|
"name": "IsFileExtension",
|
||||||
"description": "Check file extension (including point: .png, .wav)",
|
"description": "Check file extension (recommended include point: .png, .wav)",
|
||||||
"returnType": "bool",
|
"returnType": "bool",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4027,7 +4027,7 @@ return {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "IsFileExtension",
|
name = "IsFileExtension",
|
||||||
description = "Check file extension (including point: .png, .wav)",
|
description = "Check file extension (recommended include point: .png, .wav)",
|
||||||
returnType = "bool",
|
returnType = "bool",
|
||||||
params = {
|
params = {
|
||||||
{type = "const char *", name = "fileName"},
|
{type = "const char *", name = "fileName"},
|
||||||
|
|||||||
@ -1670,7 +1670,7 @@ Function 125: DirectoryExists() (1 input parameters)
|
|||||||
Function 126: IsFileExtension() (2 input parameters)
|
Function 126: IsFileExtension() (2 input parameters)
|
||||||
Name: IsFileExtension
|
Name: IsFileExtension
|
||||||
Return type: bool
|
Return type: bool
|
||||||
Description: Check file extension (including point: .png, .wav)
|
Description: Check file extension (recommended include point: .png, .wav)
|
||||||
Param[1]: fileName (type: const char *)
|
Param[1]: fileName (type: const char *)
|
||||||
Param[2]: ext (type: const char *)
|
Param[2]: ext (type: const char *)
|
||||||
Function 127: GetFileLength() (1 input parameters)
|
Function 127: GetFileLength() (1 input parameters)
|
||||||
|
|||||||
@ -1054,7 +1054,7 @@
|
|||||||
<Function name="DirectoryExists" retType="bool" paramCount="1" desc="Check if a directory path exists">
|
<Function name="DirectoryExists" retType="bool" paramCount="1" desc="Check if a directory path exists">
|
||||||
<Param type="const char *" name="dirPath" desc="" />
|
<Param type="const char *" name="dirPath" desc="" />
|
||||||
</Function>
|
</Function>
|
||||||
<Function name="IsFileExtension" retType="bool" paramCount="2" desc="Check file extension (including point: .png, .wav)">
|
<Function name="IsFileExtension" retType="bool" paramCount="2" desc="Check file extension (recommended include point: .png, .wav)">
|
||||||
<Param type="const char *" name="fileName" desc="" />
|
<Param type="const char *" name="fileName" desc="" />
|
||||||
<Param type="const char *" name="ext" desc="" />
|
<Param type="const char *" name="ext" desc="" />
|
||||||
</Function>
|
</Function>
|
||||||
|
|||||||
@ -740,6 +740,8 @@ int main(int argc, char *argv[])
|
|||||||
VALID_INVALID_CATEGORY
|
VALID_INVALID_CATEGORY
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: Log more details about the validation process
|
||||||
|
|
||||||
// Check all examples in collection [examples_list.txt] -> Source of truth!
|
// Check all examples in collection [examples_list.txt] -> Source of truth!
|
||||||
int exCollectionCount = 0;
|
int exCollectionCount = 0;
|
||||||
rlExampleInfo *exCollection = LoadExamplesData(exCollectionFilePath, "ALL", false, &exCollectionCount);
|
rlExampleInfo *exCollection = LoadExamplesData(exCollectionFilePath, "ALL", false, &exCollectionCount);
|
||||||
@ -971,8 +973,20 @@ int main(int argc, char *argv[])
|
|||||||
// Review: Add/Remove: raylib.com/examples/<category>/<category>_example_name.wasm
|
// Review: Add/Remove: raylib.com/examples/<category>/<category>_example_name.wasm
|
||||||
// Review: Add/Remove: raylib.com/examples/<category>/<category>_example_name.js
|
// Review: Add/Remove: raylib.com/examples/<category>/<category>_example_name.js
|
||||||
// Solves: VALID_MISSING_WEB_OUTPUT
|
// Solves: VALID_MISSING_WEB_OUTPUT
|
||||||
//if (exInfo->status & VALID_MISSING_WEB_OUTPUT)
|
if (exInfo->status & VALID_MISSING_WEB_OUTPUT)
|
||||||
// system(TextFormat("%s/build_example_web.bat %s/%s", exBasePath, exInfo->category, exInfo->name));
|
{
|
||||||
|
system(TextFormat("%s/build_example_web.bat %s/%s", exBasePath, exInfo->category, exInfo->name));
|
||||||
|
|
||||||
|
// Copy results to web side
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exInfo->category, exInfo->name),
|
||||||
|
TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exInfo->category, exInfo->name),
|
||||||
|
TextFormat("%s/%s/%s.data", exWebPath, exInfo->category, exInfo->name));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exInfo->category, exInfo->name),
|
||||||
|
TextFormat("%s/%s/%s.wasm", exWebPath, exInfo->category, exInfo->name));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exInfo->category, exInfo->name),
|
||||||
|
TextFormat("%s/%s/%s.js", exWebPath, exInfo->category, exInfo->name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user