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.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index e848ad8d0d3..fef102d8267 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -65,7 +65,8 @@
return -1 if zlib fails, -2 if the originating file does not exist
note: will remove the "from" file
*/
-int BLI_gzip(const char *from, const char *to) {
+int BLI_file_gzip(const char *from, const char *to)
+{
char buffer[10240];
int file;
int readsize = 0;
@@ -109,7 +110,7 @@ int BLI_gzip(const char *from, const char *to) {
/* gzip the file in from_file and write it to memery to_mem, at most size bytes.
return the unziped size
*/
-char *BLI_ungzip_to_mem(const char *from_file, int *size_r)
+char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r)
{
gzFile gzfile;
int readsize, size, alloc_size=0;
@@ -150,7 +151,7 @@ char *BLI_ungzip_to_mem(const char *from_file, int *size_r)
/* return 1 when file can be written */
-int BLI_is_writable(const char *filename)
+int BLI_file_is_writable(const char *filename)
{
int file;
@@ -178,7 +179,7 @@ int BLI_is_writable(const char *filename)
}
}
-int BLI_touch(const char *file)
+int BLI_file_touch(const char *file)
{
FILE *f = fopen(file,"r+b");
if (f != NULL) {
@@ -195,15 +196,12 @@ int BLI_touch(const char *file)
return 0;
}
-int BLI_exists(const char *file) {
- return BLI_exist(file);
-}
-
#ifdef WIN32
static char str[MAXPATHLEN+12];
-int BLI_delete(const char *file, int dir, int recursive) {
+int BLI_delete(const char *file, int dir, int recursive)
+{
int err;
if (recursive) {
@@ -220,7 +218,8 @@ int BLI_delete(const char *file, int dir, int recursive) {
return err;
}
-int BLI_move(const char *file, const char *to) {
+int BLI_move(const char *file, const char *to)
+{
int err;
// windows doesn't support moveing to a directory
@@ -245,7 +244,8 @@ int BLI_move(const char *file, const char *to) {
}
-int BLI_copy_fileops(const char *file, const char *to) {
+int BLI_copy(const char *file, const char *to)
+{
int err;
// windows doesn't support copying to a directory
@@ -270,14 +270,16 @@ int BLI_copy_fileops(const char *file, const char *to) {
return err;
}
-int BLI_link(const char *file, const char *to) {
+int BLI_create_symlink(const char *file, const char *to)
+{
callLocalErrorCallBack("Linking files is unsupported on Windows");
(void)file;
(void)to;
return 1;
}
-void BLI_recurdir_fileops(const char *dirname) {
+void BLI_dir_create_recursive(const char *dirname)
+{
char *lslash;
char tmp[MAXPATHLEN];
@@ -299,7 +301,7 @@ void BLI_recurdir_fileops(const char *dirname) {
if (lslash) {
/* Split about the last slash and recurse */
*lslash = 0;
- BLI_recurdir_fileops(tmp);
+ BLI_dir_create_recursive(tmp);
}
if(dirname[0]) /* patch, this recursive loop tries to create a nameless directory */
@@ -307,7 +309,8 @@ void BLI_recurdir_fileops(const char *dirname) {
callLocalErrorCallBack("Unable to create directory\n");
}
-int BLI_rename(const char *from, const 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 */
@@ -347,25 +350,29 @@ int BLI_delete(const char *file, int dir, int recursive)
return -1;
}
-int BLI_move(const char *file, const char *to) {
+int BLI_move(const char *file, const char *to)
+{
BLI_snprintf(str, sizeof(str), "/bin/mv -f \"%s\" \"%s\"", file, to);
return system(str);
}
-int BLI_copy_fileops(const char *file, const char *to) {
+int BLI_copy(const char *file, const char *to)
+{
BLI_snprintf(str, sizeof(str), "/bin/cp -rf \"%s\" \"%s\"", file, to);
return system(str);
}
-int BLI_link(const char *file, const char *to) {
+int BLI_create_symlink(const char *file, const char *to)
+{
BLI_snprintf(str, sizeof(str), "/bin/ln -f \"%s\" \"%s\"", file, to);
return system(str);
}
-void BLI_recurdir_fileops(const char *dirname) {
+void BLI_dir_create_recursive(const char *dirname)
+{
char *lslash;
char tmp[MAXPATHLEN];
@@ -377,13 +384,14 @@ void BLI_recurdir_fileops(const char *dirname) {
if (lslash) {
/* Split about the last slash and recurse */
*lslash = 0;
- BLI_recurdir_fileops(tmp);
+ BLI_dir_create_recursive(tmp);
}
mkdir(dirname, 0777);
}
-int BLI_rename(const char *from, const 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;
@@ -392,3 +400,4 @@ int BLI_rename(const char *from, const char *to) {
}
#endif
+