[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41196] trunk/blender/source/blender: Code cleanup: file operations merged into single header, some function names
Brecht Van Lommel
brechtvanlommel at pandora.be
Sat Oct 22 17:35:49 CEST 2011
Revision: 41196
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41196
Author: blendix
Date: 2011-10-22 15:35:49 +0000 (Sat, 22 Oct 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenfont/intern/blf_translation.c
trunk/blender/source/blender/blenkernel/intern/effect.c
trunk/blender/source/blender/blenkernel/intern/fluidsim.c
trunk/blender/source/blender/blenkernel/intern/packedFile.c
trunk/blender/source/blender/blenkernel/intern/particle_system.c
trunk/blender/source/blender/blenkernel/intern/sequencer.c
trunk/blender/source/blender/blenlib/BLI_blenlib.h
trunk/blender/source/blender/blenlib/BLI_edgehash.h
trunk/blender/source/blender/blenlib/BLI_fileops.h
trunk/blender/source/blender/blenlib/BLI_mempool.h
trunk/blender/source/blender/blenlib/BLI_scanfill.h
trunk/blender/source/blender/blenlib/CMakeLists.txt
trunk/blender/source/blender/blenlib/intern/fileops.c
trunk/blender/source/blender/blenlib/intern/path_util.c
trunk/blender/source/blender/blenloader/intern/readblenentry.c
trunk/blender/source/blender/blenloader/intern/runtime.c
trunk/blender/source/blender/blenloader/intern/writefile.c
trunk/blender/source/blender/collada/ImageExporter.cpp
trunk/blender/source/blender/collada/collada.cpp
trunk/blender/source/blender/editors/interface/interface_icons.c
trunk/blender/source/blender/editors/space_buttons/buttons_ops.c
trunk/blender/source/blender/editors/space_file/file_draw.c
trunk/blender/source/blender/editors/space_file/file_ops.c
trunk/blender/source/blender/editors/space_file/filelist.c
trunk/blender/source/blender/editors/space_file/filesel.c
trunk/blender/source/blender/editors/space_file/space_file.c
trunk/blender/source/blender/editors/space_image/image_ops.c
trunk/blender/source/blender/editors/space_node/node_edit.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c
trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp
trunk/blender/source/blender/imbuf/intern/readimage.c
trunk/blender/source/blender/imbuf/intern/thumbs.c
trunk/blender/source/blender/python/intern/bpy_interface.c
trunk/blender/source/blender/render/intern/source/pipeline.c
trunk/blender/source/blender/windowmanager/intern/wm_files.c
Added Paths:
-----------
trunk/blender/source/blender/blenlib/BLI_fileops_types.h
trunk/blender/source/blender/blenlib/intern/storage.c
Removed Paths:
-------------
trunk/blender/source/blender/blenlib/BLI_storage.h
trunk/blender/source/blender/blenlib/BLI_storage_types.h
trunk/blender/source/blender/blenlib/intern/storage.c
Modified: trunk/blender/source/blender/blenfont/intern/blf_translation.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_translation.c 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenfont/intern/blf_translation.c 2011-10-22 15:35:49 UTC (rev 41196)
@@ -60,7 +60,7 @@
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__);
Modified: trunk/blender/source/blender/blenkernel/intern/effect.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/effect.c 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenkernel/intern/effect.c 2011-10-22 15:35:49 UTC (rev 41196)
@@ -33,7 +33,6 @@
#include <stddef.h>
-#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <math.h>
#include <stdlib.h>
Modified: trunk/blender/source/blender/blenkernel/intern/fluidsim.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fluidsim.c 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenkernel/intern/fluidsim.c 2011-10-22 15:35:49 UTC (rev 41196)
@@ -33,7 +33,6 @@
#include <stddef.h>
-#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include "MEM_guardedalloc.h"
Modified: trunk/blender/source/blender/blenkernel/intern/packedFile.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/packedFile.c 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenkernel/intern/packedFile.c 2011-10-22 15:35:49 UTC (rev 41196)
@@ -192,7 +192,7 @@
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 @@
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;
Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c 2011-10-22 15:35:49 UTC (rev 41196)
@@ -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"
Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c 2011-10-22 15:35:49 UTC (rev 41196)
@@ -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"
Modified: trunk/blender/source/blender/blenlib/BLI_blenlib.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_blenlib.h 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenlib/BLI_blenlib.h 2011-10-22 15:35:49 UTC (rev 41196)
@@ -76,8 +76,6 @@
#include "BLI_path_util.h"
-#include "BLI_storage.h"
-
#include "BLI_fileops.h"
#include "BLI_rect.h"
Modified: trunk/blender/source/blender/blenlib/BLI_edgehash.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_edgehash.h 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenlib/BLI_edgehash.h 2011-10-22 15:35:49 UTC (rev 41196)
@@ -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.
Modified: trunk/blender/source/blender/blenlib/BLI_fileops.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_fileops.h 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenlib/BLI_fileops.h 2011-10-22 15:35:49 UTC (rev 41196)
@@ -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,18 +39,49 @@
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
}
#endif
Copied: trunk/blender/source/blender/blenlib/BLI_fileops_types.h (from rev 41182, trunk/blender/source/blender/blenlib/BLI_storage_types.h)
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_fileops_types.h (rev 0)
+++ trunk/blender/source/blender/blenlib/BLI_fileops_types.h 2011-10-22 15:35:49 UTC (rev 41196)
@@ -0,0 +1,80 @@
+/*
+ * $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_FILEOPS_TYPES_H
+#define BLI_FILEOPS_TYPES_H
+
+/** \file BLI_fileops_types.h
+ * \ingroup bli
+ * \brief Some types for dealing with directories.
+ */
+
+#include <sys/stat.h>
+
+#if defined(WIN32) && !defined(FREE_WINDOWS)
+typedef unsigned int mode_t;
+#endif
+
+struct ImBuf;
+
+struct direntry{
+ char *string;
+ mode_t type;
+ char *relname;
+ char *path;
+#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500)
+ struct _stat64 s;
+#elif defined(__MINGW32__)
+ struct _stati64 s;
+#else
+ struct stat s;
+#endif
+ unsigned int flags;
+ char size[16];
+ char mode1[4];
+ char mode2[4];
+ char mode3[4];
+ char owner[16];
+ char time[8];
+ char date[16];
+ char extra[16];
+ void *poin;
+ int nr;
+ struct ImBuf *image;
+ unsigned int selflag; /* selection flag */
+};
+
+struct dirlink
+{
+ struct dirlink *next,*prev;
+ char *name;
+};
+
+#endif /* BLI_FILEOPS_TYPES_H */
+
Modified: trunk/blender/source/blender/blenlib/BLI_mempool.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_mempool.h 2011-10-22 15:20:56 UTC (rev 41195)
+++ trunk/blender/source/blender/blenlib/BLI_mempool.h 2011-10-22 15:35:49 UTC (rev 41196)
@@ -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.
Modified: trunk/blender/source/blender/blenlib/BLI_scanfill.h
===================================================================
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list