Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/fileops.c')
-rw-r--r--source/blender/blenlib/intern/fileops.c94
1 files changed, 16 insertions, 78 deletions
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 06b427240ba..462e3ed9d01 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -53,74 +53,12 @@
#include "BLO_sys_types.h" // for intptr_t support
-/* implementations: */
-char *first_slash(char *string) {
- char *ffslash, *fbslash;
-
- ffslash= strchr(string, '/');
- fbslash= strchr(string, '\\');
-
- if (!ffslash) return fbslash;
- else if (!fbslash) return ffslash;
-
- if ((intptr_t)ffslash < (intptr_t)fbslash) return ffslash;
- else return fbslash;
-}
-
-char *BLI_last_slash(const char *string) {
- char *lfslash, *lbslash;
-
- lfslash= strrchr(string, '/');
- lbslash= strrchr(string, '\\');
-
- if (!lfslash) return lbslash;
- else if (!lbslash) return lfslash;
-
- if ((intptr_t)lfslash < (intptr_t)lbslash) return lbslash;
- else return lfslash;
-}
-
-/* adds a slash if there isnt one there already */
-int BLI_add_slash(char *string) {
- int len = strlen(string);
-#ifdef WIN32
- if (len==0 || string[len-1]!='\\') {
- string[len] = '\\';
- string[len+1] = '\0';
- return len+1;
- }
-#else
- if (len==0 || string[len-1]!='/') {
- string[len] = '/';
- string[len+1] = '\0';
- return len+1;
- }
-#endif
- return len;
-}
-
-/* removes a slash if there is one */
-void BLI_del_slash(char *string) {
- int len = strlen(string);
- while (len) {
-#ifdef WIN32
- if (string[len-1]=='\\') {
-#else
- if (string[len-1]=='/') {
-#endif
- string[len-1] = '\0';
- len--;
- } else {
- break;
- }
- }
-}
/* gzip the file in from and write it to "to".
return -1 if zlib fails, -2 if the originating file does not exist
note: will remove the "from" file
*/
-int BLI_gzip(char *from, char *to) {
+int BLI_gzip(const char *from, const char *to) {
char buffer[10240];
int file;
int readsize = 0;
@@ -160,7 +98,7 @@ int BLI_gzip(char *from, char *to) {
}
/* return 1 when file can be written */
-int BLI_is_writable(char *filename)
+int BLI_is_writable(const char *filename)
{
int file;
@@ -205,7 +143,7 @@ int BLI_touch(const char *file)
return 0;
}
-int BLI_exists(char *file) {
+int BLI_exists(const char *file) {
return BLI_exist(file);
}
@@ -213,7 +151,7 @@ int BLI_exists(char *file) {
static char str[MAXPATHLEN+12];
-int BLI_delete(char *file, int dir, int recursive) {
+int BLI_delete(const char *file, int dir, int recursive) {
int err;
if (recursive) {
@@ -230,7 +168,7 @@ int BLI_delete(char *file, int dir, int recursive) {
return err;
}
-int BLI_move(char *file, char *to) {
+int BLI_move(const char *file, const char *to) {
int err;
// windows doesn't support moveing to a directory
@@ -255,7 +193,7 @@ int BLI_move(char *file, char *to) {
}
-int BLI_copy_fileops(char *file, char *to) {
+int BLI_copy_fileops(const char *file, const char *to) {
int err;
// windows doesn't support copying to a directory
@@ -280,13 +218,13 @@ int BLI_copy_fileops(char *file, char *to) {
return err;
}
-int BLI_link(char *file, char *to) {
+int BLI_link(const char *file, const char *to) {
callLocalErrorCallBack("Linking files is unsupported on Windows");
return 1;
}
-void BLI_recurdir_fileops(char *dirname) {
+void BLI_recurdir_fileops(const char *dirname) {
char *lslash;
char tmp[MAXPATHLEN];
@@ -316,7 +254,7 @@ void BLI_recurdir_fileops(char *dirname) {
callLocalErrorCallBack("Unable to create directory\n");
}
-int BLI_rename(char *from, char *to) {
+int BLI_rename(const char *from, const char *to) {
if (!BLI_exists(from)) return 0;
/* make sure the filenames are different (case insensitive) before removing */
@@ -326,7 +264,7 @@ int BLI_rename(char *from, char *to) {
return rename(from, to);
}
-#else /* The weirdo UNIX world */
+#else /* The UNIX world */
/*
* but the UNIX world is tied to the interface, and the system
@@ -335,7 +273,7 @@ int BLI_rename(char *from, char *to) {
* */
static char str[MAXPATHLEN+12];
-int BLI_delete(char *file, int dir, int recursive)
+int BLI_delete(const char *file, int dir, int recursive)
{
if(strchr(file, '"')) {
printf("Error: not deleted file %s because of quote!\n", file);
@@ -356,25 +294,25 @@ int BLI_delete(char *file, int dir, int recursive)
return -1;
}
-int BLI_move(char *file, char *to) {
+int BLI_move(const char *file, const char *to) {
sprintf(str, "/bin/mv -f \"%s\" \"%s\"", file, to);
return system(str);
}
-int BLI_copy_fileops(char *file, char *to) {
+int BLI_copy_fileops(const char *file, const char *to) {
sprintf(str, "/bin/cp -rf \"%s\" \"%s\"", file, to);
return system(str);
}
-int BLI_link(char *file, char *to) {
+int BLI_link(const char *file, const char *to) {
sprintf(str, "/bin/ln -f \"%s\" \"%s\"", file, to);
return system(str);
}
-void BLI_recurdir_fileops(char *dirname) {
+void BLI_recurdir_fileops(const char *dirname) {
char *lslash;
char tmp[MAXPATHLEN];
@@ -392,7 +330,7 @@ void BLI_recurdir_fileops(char *dirname) {
mkdir(dirname, 0777);
}
-int BLI_rename(char *from, char *to) {
+int BLI_rename(const char *from, const char *to) {
if (!BLI_exists(from)) return 0;
if (BLI_exists(to)) if(BLI_delete(to, 0, 0)) return 1;