Code cleanup: file operations merged into single header, some function names

made less cryptic and changed to indicate if they work on files or directories.
This commit is contained in:
2011-10-22 15:35:49 +00:00
parent c1de5cc838
commit e417e011d5
39 changed files with 137 additions and 191 deletions

View File

@@ -60,7 +60,7 @@ unsigned char *BLF_get_unifont(int *unifont_size_r)
BLI_snprintf(unifont_path, sizeof(unifont_path), "%s/%s", fontpath, unifont_filename);
unifont_ttf= (unsigned char*)BLI_ungzip_to_mem(unifont_path, &unifont_size);
unifont_ttf= (unsigned char*)BLI_file_ungzip_to_mem(unifont_path, &unifont_size);
}
else {
printf("%s: 'fonts' data path not found for international font, continuing\n", __func__);

View File

@@ -33,7 +33,6 @@
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <math.h>
#include <stdlib.h>

View File

@@ -33,7 +33,6 @@
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include "MEM_guardedalloc.h"

View File

@@ -192,7 +192,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
if (file <= 0) {
BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name);
} else {
filelen = BLI_filesize(file);
filelen = BLI_file_descriptor_size(file);
if (filelen == 0) {
// MEM_mallocN complains about MEM_mallocN(0, "bla");
@@ -283,7 +283,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
for (number = 1; number <= 999; number++) {
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number);
if (! BLI_exists(tempname)) {
if (BLI_copy_fileops(name, tempname) == RET_OK) {
if (BLI_copy(name, tempname) == RET_OK) {
remove_tmp = TRUE;
}
break;

View File

@@ -36,7 +36,6 @@
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <stdlib.h>
#include <math.h>
@@ -64,7 +63,7 @@
#include "BLI_rand.h"
#include "BLI_jitter.h"
#include "BLI_math.h"
#include "BLI_blenlib.h" /* BLI_storage.h For _LARGEFILE64_SOURCE; zlib needs this on some systems */
#include "BLI_blenlib.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
#include "BLI_threads.h"

View File

@@ -51,7 +51,6 @@
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_storage.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"

View File

@@ -76,8 +76,6 @@ extern "C" {
#include "BLI_path_util.h"
#include "BLI_storage.h"
#include "BLI_fileops.h"
#include "BLI_rect.h"

View File

@@ -30,7 +30,7 @@
#ifndef BLI_EDGEHASH_H
#define BLI_EDGEHASH_H
/** \file BLI_storage.h
/** \file BLI_edgehash.h
* \ingroup bli
* \author Daniel Dunbar
* \brief A general unordered 2-int pair hash table ADT.

View File

@@ -29,10 +29,7 @@
/** \file BLI_fileops.h
* \ingroup bli
* \author Daniel Dunbar
* \brief More low-level fileops from Daniel Dunbar. Two functions were also
* defined in storage.c. These are the old fop_ prefixes. There is
* definitely some redundancy here!
* \brief File and directory operations.
* */
#ifndef BLI_FILEOPS_H
@@ -42,17 +39,48 @@
extern "C" {
#endif
void BLI_recurdir_fileops(const char *dirname);
int BLI_link(const char *file, const char *to);
int BLI_is_writable(const char *filename);
#include "BLI_fileops_types.h"
int BLI_copy_fileops(const char *file, const char *to);
int BLI_rename(const char *from, const char *to);
int BLI_gzip(const char *from, const char *to);
char *BLI_ungzip_to_mem(const char *from_file, int *size_r);
int BLI_delete(const char *file, int dir, int recursive);
int BLI_move(const char *file, const char *to);
int BLI_touch(const char *file);
/* for size_t (needed on windows) */
#include <stddef.h>
/* Common */
int BLI_exists(const char *path);
int BLI_copy(const char *path, const char *to);
int BLI_rename(const char *from, const char *to);
int BLI_delete(const char *path, int dir, int recursive);
int BLI_move(const char *path, const char *to);
int BLI_create_symlink(const char *path, const char *to);
/* Directories */
struct direntry;
int BLI_is_dir(const char *path);
void BLI_dir_create_recursive(const char *dir);
double BLI_dir_free_space(const char *dir);
char *BLI_current_working_dir(char *dir, const int maxlen);
unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist);
/* Files */
int BLI_file_is_writable(const char *file);
int BLI_file_touch(const char *file);
int BLI_file_gzip(const char *from, const char *to);
char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r);
size_t BLI_file_descriptor_size(int file);
size_t BLI_file_size(const char *file);
/* compare if one was last modified before the other */
int BLI_file_older(const char *file1, const char *file2);
/* read ascii file as lines, empty list if reading fails */
struct LinkNode *BLI_file_read_as_lines(const char *file);
void BLI_file_free_lines(struct LinkNode *lines);
#ifdef __cplusplus
}

View File

@@ -26,10 +26,11 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BLI_STORAGE_TYPES_H
#define BLI_STORAGE_TYPES_H
/** \file BLI_storage_types.h
#ifndef BLI_FILEOPS_TYPES_H
#define BLI_FILEOPS_TYPES_H
/** \file BLI_fileops_types.h
* \ingroup bli
* \brief Some types for dealing with directories.
*/
@@ -75,5 +76,5 @@ struct dirlink
char *name;
};
#endif /* BLI_STORAGE_TYPES_H */
#endif /* BLI_FILEOPS_TYPES_H */

View File

@@ -29,7 +29,7 @@
#ifndef BLI_MEMPOOL_H
#define BLI_MEMPOOL_H
/** \file BLI_storage.h
/** \file BLI_mempool.h
* \ingroup bli
* \author Geoffrey Bantle
* \brief Simple fast memory allocator.

View File

@@ -30,7 +30,7 @@
#ifndef BLI_SCANFILL_H
#define BLI_SCANFILL_H
/** \file BLI_storage.h
/** \file BLI_scanfill.h
* \ingroup bli
* \since March 2001
* \author nzc

View File

@@ -1,71 +0,0 @@
/* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BLI_STORAGE_H
#define BLI_STORAGE_H
/** \file BLI_storage.h
* \ingroup bli
*/
/* for size_t (needed on windows) */
#include <stddef.h>
struct direntry;
size_t BLI_filesize(int file);
size_t BLI_filepathsize(const char *path);
double BLI_diskfree(const char *dir);
char *BLI_getwdN(char *dir, const int maxncpy);
unsigned int BLI_getdir(const char *dirname, struct direntry **filelist);
/* test if file or directory exists */
int BLI_exists(const char *name);
/* test if there is a directory at the specified path */
int BLI_is_dir(const char *file);
/**
* Read a file as ASCII lines. An empty list is
* returned if the file cannot be opened or read.
*
* @attention The returned list should be free'd with
* BLI_free_file_lines.
*
* @param name The name of the file to read.
* @retval A list of strings representing the file lines.
*/
struct LinkNode *BLI_read_file_as_lines(const char *name);
void BLI_free_file_lines(struct LinkNode *lines);
/* Compare if one was last modified before the other */
int BLI_file_older(const char *file1, const char *file2);
#endif /* BLI_STORAGE_H */

View File

@@ -99,6 +99,7 @@ set(SRC
BLI_edgehash.h
BLI_editVert.h
BLI_fileops.h
BLI_fileops_types.h
BLI_fnmatch.h
BLI_ghash.h
BLI_graph.h
@@ -125,8 +126,6 @@ set(SRC
BLI_rand.h
BLI_rect.h
BLI_scanfill.h
BLI_storage.h
BLI_storage_types.h
BLI_string.h
BLI_string_utf8.h
BLI_threads.h

View File

@@ -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) {
@@ -199,7 +200,8 @@ int BLI_touch(const char *file)
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) {
@@ -216,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
@@ -241,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
@@ -266,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];
@@ -295,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 */
@@ -303,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 */
@@ -343,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];
@@ -373,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;
@@ -388,3 +400,4 @@ int BLI_rename(const char *from, const char *to) {
}
#endif

View File

@@ -46,8 +46,6 @@
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_storage.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BKE_utildefines.h"
@@ -740,7 +738,7 @@ int BLI_path_cwd(char *path)
if (wasrelative==1) {
char cwd[FILE_MAXDIR + FILE_MAXFILE]= "";
BLI_getwdN(cwd, sizeof(cwd)); /* incase the full path to the blend isnt used */
BLI_current_working_dir(cwd, sizeof(cwd)); /* incase the full path to the blend isnt used */
if (cwd[0] == '\0') {
printf( "Could not get the current working directory - $PWD for an unknown reason.");
@@ -986,7 +984,7 @@ static int get_path_system(char *targetpath, const char *folder_name, const char
}
/* try CWD/release/folder_name */
if(BLI_getwdN(cwd, sizeof(cwd))) {
if(BLI_current_working_dir(cwd, sizeof(cwd))) {
if(test_path(targetpath, cwd, "release", relfolder)) {
return 1;
}
@@ -1117,7 +1115,7 @@ char *BLI_get_folder_create(int folder_id, const char *subfolder)
if (!path) {
path = BLI_get_user_folder_notest(folder_id, subfolder);
if (path) BLI_recurdir_fileops(path);
if (path) BLI_dir_create_recursive(path);
}
return path;
@@ -1250,7 +1248,7 @@ void BLI_make_existing_file(const char *name)
/* test exist */
if (BLI_exists(di) == 0) {
BLI_recurdir_fileops(di);
BLI_dir_create_recursive(di);
}
}
@@ -1732,7 +1730,7 @@ static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name
BLI_strncpy(fullname, name, maxlen);
if (name[0] == '.') {
char wdir[FILE_MAX]= "";
BLI_getwdN(wdir, sizeof(wdir)); /* backup cwd to restore after */
BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */
// not needed but avoids annoying /./ in name
if(name[1]==SEP)

View File

@@ -88,10 +88,9 @@
#include "DNA_listBase.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_linklist.h"
#include "BLI_storage.h"
#include "BLI_storage_types.h"
#include "BLI_string.h"
#include "BKE_utildefines.h"
@@ -104,7 +103,7 @@ static struct ListBase dirbase_={NULL, NULL};
static struct ListBase *dirbase = &dirbase_;
/* can return NULL when the size is not big enough */
char *BLI_getwdN(char *dir, const int maxncpy)
char *BLI_current_working_dir(char *dir, const int maxncpy)
{
const char *pwd= getenv("PWD");
if (pwd){
@@ -116,7 +115,7 @@ char *BLI_getwdN(char *dir, const int maxncpy)
}
int BLI_compare(struct direntry *entry1, struct direntry *entry2)
static int bli_compare(struct direntry *entry1, struct direntry *entry2)
{
/* type is equal to stat.st_mode */
@@ -143,7 +142,7 @@ int BLI_compare(struct direntry *entry1, struct direntry *entry2)
}
double BLI_diskfree(const char *dir)
double BLI_dir_free_space(const char *dir)
{
#ifdef WIN32
DWORD sectorspc, bytesps, freec, clusters;
@@ -198,7 +197,7 @@ double BLI_diskfree(const char *dir)
#endif
}
void BLI_builddir(const char *dirname, const char *relname)
static void bli_builddir(const char *dirname, const char *relname)
{
struct dirent *fname;
struct dirlink *dlink;
@@ -273,7 +272,7 @@ void BLI_builddir(const char *dirname, const char *relname)
}
BLI_freelist(dirbase);
if (files) qsort(files, actnum, sizeof(struct direntry), (int (*)(const void *,const void*))BLI_compare);
if (files) qsort(files, actnum, sizeof(struct direntry), (int (*)(const void *,const void*))bli_compare);
} else {
printf("%s empty directory\n",dirname);
}
@@ -284,7 +283,7 @@ void BLI_builddir(const char *dirname, const char *relname)
}
}
void BLI_adddirstrings(void)
static void bli_adddirstrings(void)
{
char datum[100];
char buf[512];
@@ -392,7 +391,7 @@ void BLI_adddirstrings(void)
}
}
unsigned int BLI_getdir(const char *dirname, struct direntry **filelist)
unsigned int BLI_dir_contents(const char *dirname, struct direntry **filelist)
{
// reset global variables
// memory stored in files is free()'d in
@@ -401,8 +400,8 @@ unsigned int BLI_getdir(const char *dirname, struct direntry **filelist)
actnum = totnum = 0;
files = NULL;
BLI_builddir(dirname,"");
BLI_adddirstrings();
bli_builddir(dirname,"");
bli_adddirstrings();
if (files) {
*(filelist) = files;
@@ -416,7 +415,7 @@ unsigned int BLI_getdir(const char *dirname, struct direntry **filelist)
}
size_t BLI_filesize(int file)
size_t BLI_file_descriptor_size(int file)
{
struct stat buf;
@@ -425,14 +424,14 @@ size_t BLI_filesize(int file)
return (buf.st_size);
}
size_t BLI_filepathsize(const char *path)
size_t BLI_file_size(const char *path)
{
int size, file = open(path, O_BINARY|O_RDONLY);
if (file == -1)
return -1;
size = BLI_filesize(file);
size = BLI_file_descriptor_size(file);
close(file);
return size;
}
@@ -474,7 +473,7 @@ int BLI_is_dir(const char *file)
return S_ISDIR(BLI_exists(file));
}
LinkNode *BLI_read_file_as_lines(const char *name)
LinkNode *BLI_file_read_as_lines(const char *name)
{
FILE *fp= fopen(name, "r");
LinkNode *lines= NULL;
@@ -515,7 +514,7 @@ LinkNode *BLI_read_file_as_lines(const char *name)
return lines;
}
void BLI_free_file_lines(LinkNode *lines)
void BLI_file_free_lines(LinkNode *lines)
{
BLI_linklist_free(lines, (void(*)(void*)) MEM_freeN);
}

View File

@@ -34,7 +34,6 @@
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <stdlib.h>
#include <string.h>
@@ -43,11 +42,12 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_fileops.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_genfile.h"
#include "DNA_sdna_types.h"

View File

@@ -111,7 +111,7 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
goto cleanup;
}
actualsize= BLI_filesize(fd);
actualsize= BLI_file_descriptor_size(fd);
lseek(fd, -12, SEEK_END);

View File

@@ -2734,7 +2734,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
/* first write compressed to separate @.gz */
BLI_snprintf(gzname, sizeof(gzname), "%s@.gz", filepath);
ret = BLI_gzip(tempname, gzname);
ret = BLI_file_gzip(tempname, gzname);
if(0==ret) {
/* now rename to real file name, and delete temp @ file too */

View File

@@ -110,7 +110,7 @@ void ImagesExporter::operator()(Material *ma, Object *ob)
// make dest directory if it doesn't exist
BLI_make_existing_file(abs);
if (BLI_copy_fileops(src, abs) != 0) {
if (BLI_copy(src, abs) != 0) {
fprintf(stderr, "Cannot copy image to file's directory. \n");
}
}

View File

@@ -40,9 +40,8 @@ extern "C"
#include "BKE_context.h"
/* make dummy file */
#include "BLI_storage.h"
#include "BLI_path_util.h"
#include "BLI_fileops.h"
#include "BLI_path_util.h"
int collada_import(bContext *C, const char *filepath)
{
@@ -62,7 +61,7 @@ extern "C"
/* annoying, collada crashes if file cant be created! [#27162] */
if(!BLI_exists(filepath)) {
BLI_make_existing_file(filepath); /* makes the dir if its not there */
if(BLI_touch(filepath) == 0) {
if(BLI_file_touch(filepath) == 0) {
return 0;
}
}

View File

@@ -47,7 +47,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
@@ -609,11 +608,11 @@ static void init_iconfile_list(struct ListBase *list)
if(icondir==NULL)
return;
/* since BLI_getdir changes the current working directory, restore it
/* since BLI_dir_contents changes the current working directory, restore it
back to old value afterwards */
if(!BLI_getwdN(olddir, sizeof(olddir)))
if(!BLI_current_working_dir(olddir, sizeof(olddir)))
restoredir = 0;
totfile = BLI_getdir(icondir, &dir);
totfile = BLI_dir_contents(icondir, &dir);
if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */
for(i=0; i<totfile; i++) {
@@ -662,7 +661,7 @@ static void init_iconfile_list(struct ListBase *list)
}
}
/* free temporary direntry structure that's been created by BLI_getdir() */
/* free temporary direntry structure that's been created by BLI_dir_contents() */
i= totfile-1;
for(; i>=0; i--){

View File

@@ -39,7 +39,6 @@
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "BLI_storage.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"

View File

@@ -37,7 +37,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_dynstr.h"
#include "BLI_storage_types.h"
#ifdef WIN32
#include "BLI_winstuff.h"
#endif

View File

@@ -39,7 +39,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_storage_types.h"
#ifdef WIN32
#include "BLI_winstuff.h"
#endif
@@ -1042,7 +1041,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
}
/* create the file */
BLI_recurdir_fileops(path);
BLI_dir_create_recursive(path);
if (!BLI_exists(path)) {
BKE_report(op->reports,RPT_ERROR, "Couldn't create new folder");
@@ -1136,7 +1135,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
file_expand_directory(C);
if (!BLI_exists(sfile->params->dir)) {
BLI_recurdir_fileops(sfile->params->dir);
BLI_dir_create_recursive(sfile->params->dir);
}
/* special case, user may have pasted a fulepath into the directory */

View File

@@ -48,7 +48,6 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_storage_types.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
@@ -825,10 +824,10 @@ static void filelist_read_dir(struct FileList* filelist)
filelist->fidx = NULL;
filelist->filelist = NULL;
BLI_getwdN(wdir, sizeof(wdir)); /* backup cwd to restore after */
BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */
BLI_cleanup_dir(G.main->name, filelist->dir);
filelist->numfiles = BLI_getdir(filelist->dir, &(filelist->filelist));
filelist->numfiles = BLI_dir_contents(filelist->dir, &(filelist->filelist));
if(!chdir(wdir)) {} /* fix warning about not checking return value */
filelist_setfiletypes(filelist);

View File

@@ -64,7 +64,6 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_storage_types.h"
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"

View File

@@ -46,7 +46,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"

View File

@@ -143,7 +143,7 @@ static int space_image_file_exists_poll(bContext *C)
if(ibuf) {
BLI_strncpy(name, ibuf->name, FILE_MAX);
BLI_path_abs(name, bmain->name);
poll= (BLI_exists(name) && BLI_is_writable(name));
poll= (BLI_exists(name) && BLI_file_is_writable(name));
}
ED_space_image_release_buffer(sima, lock);
@@ -1223,7 +1223,7 @@ static int save_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
save_image_options_from_op(&simopts, op);
if (BLI_exists(simopts.filepath) && BLI_is_writable(simopts.filepath)) {
if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
save_image_doit(C, sima, op, &simopts, FALSE);
}
else {

View File

@@ -49,7 +49,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -66,10 +65,6 @@
#include "BKE_texture.h"
#include "BKE_report.h"
#include "BLI_math.h"
#include "BLI_storage_types.h"
#include "RE_pipeline.h"
#include "IMB_imbuf_types.h"

View File

@@ -44,7 +44,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "DNA_scene_types.h"

View File

@@ -45,7 +45,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BLI_threads.h"
@@ -883,7 +882,7 @@ static void UNUSED_FUNCTION(touch_seq_files)(Scene *scene)
if(seq->type==SEQ_MOVIE) {
if(seq->strip && seq->strip->stripdata) {
BLI_make_file_string(G.main->name, str, seq->strip->dir, seq->strip->stripdata->name);
BLI_touch(seq->name);
BLI_file_touch(seq->name);
}
}

View File

@@ -546,7 +546,7 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig
{
ExrHandle *data= (ExrHandle *)handle;
if(BLI_exists(filename) && BLI_filepathsize(filename)>32) { /* 32 is arbitrary, but zero length files crashes exr */
if(BLI_exists(filename) && BLI_file_size(filename)>32) { /* 32 is arbitrary, but zero length files crashes exr */
data->ifile = new InputFile(filename);
if(data->ifile) {
Box2i dw = data->ifile->header().dataWindow();

View File

@@ -88,7 +88,7 @@ ImBuf *IMB_loadifffile(int file, int flags)
if(file == -1) return NULL;
size= BLI_filesize(file);
size= BLI_file_descriptor_size(file);
mem= mmap(NULL, size, PROT_READ, MAP_SHARED, file, 0);
if(mem==(unsigned char*)-1) {
@@ -175,7 +175,7 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int
if(file == -1) return;
size= BLI_filesize(file);
size= BLI_file_descriptor_size(file);
mem= mmap(NULL, size, PROT_READ, MAP_SHARED, file, 0);
if(mem==(unsigned char*)-1) {

View File

@@ -237,10 +237,10 @@ void IMB_thumb_makedirs(void)
{
char tpath[FILE_MAX];
if (get_thumb_dir(tpath, THB_NORMAL)) {
BLI_recurdir_fileops(tpath);
BLI_dir_create_recursive(tpath);
}
if (get_thumb_dir(tpath, THB_FAIL)) {
BLI_recurdir_fileops(tpath);
BLI_dir_create_recursive(tpath);
}
}
@@ -277,7 +277,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
/* exception, skip images over 100mb */
if(source == THB_SOURCE_IMAGE) {
const size_t size= BLI_filepathsize(path);
const size_t size= BLI_file_size(path);
if(size != -1 && size > THUMB_SIZE_MAX) {
// printf("file too big: %d, skipping %s\n", (int)size, path);
return NULL;

View File

@@ -674,7 +674,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
#ifdef WITH_PYTHON_MODULE
#include "BLI_storage.h"
#include "BLI_fileops.h"
/* TODO, reloading the module isnt functional at the moment. */
static void bpy_module_free(void *mod);

View File

@@ -2753,7 +2753,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
scene_unique_exr_name(scene, str, 0);
if (BLI_is_writable(str)==0) {
if (BLI_file_is_writable(str)==0) {
BKE_report(reports, RPT_ERROR, "Can not save render buffers, check the temp default path");
return 0;
}
@@ -3152,7 +3152,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
}
if(scene->r.mode & R_TOUCH && !BLI_exists(name)) {
BLI_make_existing_file(name); /* makes the dir if its not there */
BLI_touch(name);
BLI_file_touch(name);
}
}
@@ -3175,7 +3175,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
if(G.afbreek==1) {
/* remove touched file */
if(BKE_imtype_is_movie(scene->r.imtype) == 0) {
if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_filepathsize(name) == 0) {
if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_file_size(name) == 0) {
BLI_delete(name, 0, 0);
}
}

View File

@@ -574,7 +574,7 @@ void WM_read_history(void)
BLI_make_file_string("/", name, cfgdir, BLENDER_HISTORY_FILE);
lines= BLI_read_file_as_lines(name);
lines= BLI_file_read_as_lines(name);
G.recent_files.first = G.recent_files.last = NULL;
@@ -589,7 +589,7 @@ void WM_read_history(void)
}
}
BLI_free_file_lines(lines);
BLI_file_free_lines(lines);
}