diff options
| author | Ray <[email protected]> | 2018-10-25 16:45:30 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-10-25 16:45:30 +0200 |
| commit | 78064dee09f5dea69d4e5ffea9a1ba695bbd196c (patch) | |
| tree | 60aa4aea648233d6eabbf85ced57b490211ab0cb /src | |
| parent | 0f0d271a858be8c6a22ee7e4ea18f1d817810e88 (diff) | |
| parent | b13c9716e48baac89a72d2c394b297b79e7384ef (diff) | |
| download | raylib-78064dee09f5dea69d4e5ffea9a1ba695bbd196c.tar.gz raylib-78064dee09f5dea69d4e5ffea9a1ba695bbd196c.zip | |
Merge pull request #676 from jubalh/pathdefines
Pathdefines
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -158,6 +158,7 @@ unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod); unsigned int __stdcall timeEndPeriod(unsigned int uPeriod); #endif + #elif defined(__linux__) #include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX @@ -172,9 +173,17 @@ //#define GLFW_EXPOSE_NATIVE_COCOA // WARNING: Fails due to type redefinition #define GLFW_EXPOSE_NATIVE_NSGL #include <GLFW/glfw3native.h> // Required for: glfwGetCocoaWindow(), glfwGetNSGLContext() + #endif #endif +#if defined(__linux__) + #include <linux/limits.h> // for NAME_MAX and PATH_MAX defines + #define MAX_FILEPATH_LENGTH PATH_MAX // Use Linux define (4096) +#else + #define MAX_FILEPATH_LENGTH 256 // Use common value +#endif + #if defined(PLATFORM_ANDROID) //#include <android/sensor.h> // Android sensors functions (accelerometer, gyroscope, light...) #include <android/window.h> // Defines AWINDOW_FLAG_FULLSCREEN and others @@ -1596,8 +1605,8 @@ const char *GetFileNameWithoutExt(const char *filePath) const char *GetDirectoryPath(const char *fileName) { const char *lastSlash = NULL; - static char filePath[256]; // MAX_DIRECTORY_PATH_SIZE = 256 - memset(filePath, 0, 256); + static char filePath[MAX_FILEPATH_LENGTH]; + memset(filePath, 0, MAX_FILEPATH_LENGTH); lastSlash = strprbrk(fileName, "\\/"); if (!lastSlash) return NULL; @@ -1612,19 +1621,18 @@ const char *GetDirectoryPath(const char *fileName) // Get current working directory const char *GetWorkingDirectory(void) { - static char currentDir[256]; // MAX_DIRECTORY_PATH_SIZE = 256 - memset(currentDir, 0, 256); + static char currentDir[MAX_FILEPATH_LENGTH]; + memset(currentDir, 0, MAX_FILEPATH_LENGTH); - GETCWD(currentDir, 256 - 1); + GETCWD(currentDir, MAX_FILEPATH_LENGTH - 1); return currentDir; } -// Get filenames in a directory path (max 256 files) +// Get filenames in a directory path (max 512 files) // NOTE: Files count is returned by parameters pointer char **GetDirectoryFiles(const char *dirPath, int *fileCount) { - #define MAX_FILEPATH_LENGTH 256 #define MAX_DIRECTORY_FILES 512 ClearDirectoryFiles(); @@ -3289,7 +3297,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths for (int i = 0; i < count; i++) { - dropFilesPath[i] = (char *)malloc(sizeof(char)*256); // Max path length set to 256 char + dropFilesPath[i] = (char *)malloc(sizeof(char)*MAX_FILEPATH_LENGTH); // Max path length using MAX_FILEPATH_LENGTH set to 256 char strcpy(dropFilesPath[i], paths[i]); } @@ -3862,7 +3870,7 @@ static void RestoreKeyboard(void) // Mouse initialization (including mouse thread) static void InitMouse(void) { - char Path[256]; + char Path[MAX_FILEPATH_LENGTH]; DIR *directory; struct dirent *entity; |
