Ver código fonte

Added function GetFileName()

Review comments
pull/432/head
raysan5 7 anos atrás
pai
commit
1a82e1ab26
2 arquivos alterados com 16 adições e 4 exclusões
  1. +12
    -1
      src/core.c
  2. +4
    -3
      src/raylib.h

+ 12
- 1
src/core.c Ver arquivo

@ -1174,7 +1174,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
return result;
}
// Get the extension for a filename
// Get pointer to extension for a filename string
const char *GetExtension(const char *fileName)
{
const char *dot = strrchr(fileName, '.');
@ -1184,6 +1184,17 @@ const char *GetExtension(const char *fileName)
return (dot + 1);
}
// Get pointer to filename for a path string
const char *GetFileName(const char *filePath)
{
const char *fileName = strrchr(filePath, '\\');
if (!fileName || fileName == filePath) return filePath;
return fileName + 1;
}
// Get directory for a given fileName (with path)
const char *GetDirectoryPath(const char *fileName)
{

+ 4
- 3
src/raylib.h Ver arquivo

@ -736,9 +736,10 @@ RLAPI int GetRandomValue(int min, int max); // Returns a r
// Files management functions
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
RLAPI const char *GetExtension(const char *fileName); // Get file extension
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
RLAPI const char *GetExtension(const char *fileName); // Get pointer to extension for a filename string
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
RLAPI const char *GetDirectoryPath(const char *fileName); // Get full path for a given fileName (uses static string)
RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string)
RLAPI bool ChangeDirectory(const char *dir); // Change working directory, returns true if success
RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window
RLAPI char **GetDroppedFiles(int *count); // Get dropped files names

Carregando…
Cancelar
Salvar