diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-26 18:58:02 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-26 18:59:24 +0300 |
commit | 7bc6fbf158556331e247b714f874b919b9af9ae7 (patch) | |
tree | c5b3c883d6a4243f2f11bbac9306abdee07e1207 /source/blender/blenlib/BLI_path_util.h | |
parent | fca515838e70f8bec7028b840bb921a1be9fabbb (diff) |
Cleanup: current/parent paths: add helpers in BLI_path_utils.
Also, avoid calling ugly strcmp with '.' or '..', making direct char checks is
much cheaper here!
Diffstat (limited to 'source/blender/blenlib/BLI_path_util.h')
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 8daaff1cea6..7103f8a7597 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -165,6 +165,15 @@ void BLI_string_to_utf8(char *original, char *utf_8, const char *code); # define FILE_MAX 1024 #endif +/* Parent and current dir helpers. */ +#define FILENAME_PARENT ".." +#define FILENAME_CURRENT "." + +/* Avoid calling strcmp on one or two chars! */ +#define FILENAME_IS_PARENT(_n) (((_n)[0] == '.') && ((_n)[1] == '.') && ((_n)[2] == '\0')) +#define FILENAME_IS_CURRENT(_n) (((_n)[0] == '.') && ((_n)[1] == '\0')) +#define FILENAME_IS_CURRPAR(_n) (((_n)[0] == '.') && (((_n)[1] == '\0') || (((_n)[1] == '.') && ((_n)[2] == '\0')))) + #ifdef __cplusplus } #endif |