| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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 | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * Reorganised mar-01 nzc | 
					
						
							|  |  |  |  * Some really low-level file thingies. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-27 20:37:56 +00:00
										 |  |  | /** \file blender/blenlib/intern/storage.c
 | 
					
						
							|  |  |  |  *  \ingroup bli | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #include <sys/types.h>
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef WIN32
 | 
					
						
							| 
									
										
										
										
											2013-04-24 20:19:01 +00:00
										 |  |  | #  include <dirent.h>
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <time.h>
 | 
					
						
							|  |  |  | #include <sys/stat.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-07 13:39:00 +11:00
										 |  |  | #if defined(__NetBSD__) || defined(__DragonFly__) || defined(__sun__) || defined(__sun)
 | 
					
						
							|  |  |  |    /* Other modern unix os's should probably use this also */ | 
					
						
							|  |  |  | #  include <sys/statvfs.h>
 | 
					
						
							|  |  |  | #  define USE_STATFS_STATVFS
 | 
					
						
							|  |  |  | #elif (defined(__sparc) || defined(__sparc__)) && !defined(__FreeBSD__) && !defined(__linux__)
 | 
					
						
							| 
									
										
										
										
											2013-04-24 20:19:01 +00:00
										 |  |  | #  include <sys/statfs.h>
 | 
					
						
							| 
									
										
										
										
											2014-01-07 13:39:00 +11:00
										 |  |  |    /* 4 argument version (not common) */ | 
					
						
							|  |  |  | #  define USE_STATFS_4ARGS
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-07 13:39:00 +11:00
										 |  |  | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
 | 
					
						
							|  |  |  |    /* For statfs */ | 
					
						
							| 
									
										
										
										
											2013-04-24 20:19:01 +00:00
										 |  |  | #  include <sys/param.h>
 | 
					
						
							|  |  |  | #  include <sys/mount.h>
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-07 13:39:00 +11:00
										 |  |  | #if defined(__linux__) || defined(__hpux) || defined(__GNU__) || defined(__GLIBC__)
 | 
					
						
							|  |  |  | #  include <sys/vfs.h>
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <fcntl.h>
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | #include <string.h>  /* strcpy etc.. */
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-06 13:20:05 +00:00
										 |  |  | #ifdef WIN32
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:54:07 +00:00
										 |  |  | #  include <io.h>
 | 
					
						
							|  |  |  | #  include <direct.h>
 | 
					
						
							|  |  |  | #  include "BLI_winstuff.h"
 | 
					
						
							|  |  |  | #  include "utfconv.h"
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #  include <sys/ioctl.h>
 | 
					
						
							|  |  |  | #  include <unistd.h>
 | 
					
						
							|  |  |  | #  include <pwd.h>
 | 
					
						
							| 
									
										
										
										
											2009-09-06 13:20:05 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | /* lib includes */ | 
					
						
							|  |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_listBase.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-13 17:46:30 +00:00
										 |  |  | #include "BLI_listbase.h"
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #include "BLI_linklist.h"
 | 
					
						
							| 
									
										
										
										
											2009-12-13 17:46:30 +00:00
										 |  |  | #include "BLI_string.h"
 | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | #include "BLI_fileops.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-03 22:04:14 +00:00
										 |  |  | #include "BLI_fileops_types.h"
 | 
					
						
							|  |  |  | #include "BLI_path_util.h"
 | 
					
						
							| 
									
										
										
										
											2006-03-19 13:28:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | #include "../imbuf/IMB_imbuf.h"
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Copies the current working directory into *dir (max size maxncpy), and | 
					
						
							|  |  |  |  * returns a pointer to same. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \note can return NULL when the size is not big enough | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-07-01 22:19:19 +00:00
										 |  |  | char *BLI_current_working_dir(char *dir, const size_t maxncpy) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	const char *pwd = getenv("PWD"); | 
					
						
							| 
									
										
										
										
											2012-02-27 10:35:39 +00:00
										 |  |  | 	if (pwd) { | 
					
						
							| 
									
										
										
										
											2011-02-12 10:37:37 +00:00
										 |  |  | 		BLI_strncpy(dir, pwd, maxncpy); | 
					
						
							|  |  |  | 		return dir; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-02-12 10:37:37 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return getcwd(dir, maxncpy); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Ordering function for sorting lists of files/directories. Returns -1 if | 
					
						
							|  |  |  |  * entry1 belongs before entry2, 0 if they are equal, 1 if they should be swapped. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-22 15:35:49 +00:00
										 |  |  | static int bli_compare(struct direntry *entry1, struct direntry *entry2) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-04-26 16:02:26 +00:00
										 |  |  | 	/* type is equal to stat.st_mode */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	/* directories come before non-directories */ | 
					
						
							| 
									
										
										
										
											2012-02-27 10:35:39 +00:00
										 |  |  | 	if (S_ISDIR(entry1->type)) { | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		if (S_ISDIR(entry2->type) == 0) return (-1); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		if (S_ISDIR(entry2->type)) return (1); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	/* non-regular files come after regular files */ | 
					
						
							| 
									
										
										
										
											2012-02-27 10:35:39 +00:00
										 |  |  | 	if (S_ISREG(entry1->type)) { | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		if (S_ISREG(entry2->type) == 0) return (-1); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		if (S_ISREG(entry2->type)) return (1); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	/* arbitrary, but consistent, ordering of different types of non-regular files */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); | 
					
						
							|  |  |  | 	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* OK, now we know their S_IFMT fields are the same, go on to a name comparison */ | 
					
						
							| 
									
										
										
										
											2005-01-03 14:17:33 +00:00
										 |  |  | 	/* make sure "." and ".." are always first */ | 
					
						
							| 
									
										
										
										
											2015-01-26 16:58:02 +01:00
										 |  |  | 	if (FILENAME_IS_CURRENT(entry1->relname)) return (-1); | 
					
						
							|  |  |  | 	if (FILENAME_IS_CURRENT(entry2->relname)) return (1); | 
					
						
							|  |  |  | 	if (FILENAME_IS_PARENT(entry1->relname)) return (-1); | 
					
						
							|  |  |  | 	if (FILENAME_IS_PARENT(entry2->relname)) return (1); | 
					
						
							| 
									
										
										
										
											2009-03-11 23:22:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 	return (BLI_natstrcmp(entry1->relname, entry2->relname)); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Returns the number of free bytes on the volume containing the specified pathname. */ | 
					
						
							|  |  |  | /* Not actually used anywhere.
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-22 15:35:49 +00:00
										 |  |  | double BLI_dir_free_space(const char *dir) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							|  |  |  | #ifdef WIN32
 | 
					
						
							|  |  |  | 	DWORD sectorspc, bytesps, freec, clusters; | 
					
						
							|  |  |  | 	char tmp[4]; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	tmp[0] = '\\'; tmp[1] = 0; /* Just a failsafe */ | 
					
						
							|  |  |  | 	if (dir[0] == '/' || dir[0] == '\\') { | 
					
						
							|  |  |  | 		tmp[0] = '\\'; | 
					
						
							|  |  |  | 		tmp[1] = 0; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	else if (dir[1] == ':') { | 
					
						
							|  |  |  | 		tmp[0] = dir[0]; | 
					
						
							|  |  |  | 		tmp[1] = ':'; | 
					
						
							|  |  |  | 		tmp[2] = '\\'; | 
					
						
							|  |  |  | 		tmp[3] = 0; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 	GetDiskFreeSpace(tmp, §orspc, &bytesps, &freec, &clusters); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	return (double) (freec * bytesps * sectorspc); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2008-01-26 20:36:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-07 13:39:00 +11:00
										 |  |  | #ifdef USE_STATFS_STATVFS
 | 
					
						
							| 
									
										
										
										
											2008-01-26 20:36:14 +00:00
										 |  |  | 	struct statvfs disk; | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	struct statfs disk; | 
					
						
							| 
									
										
										
										
											2008-01-26 20:36:14 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-01-07 13:39:00 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 	char name[FILE_MAXDIR], *slash; | 
					
						
							| 
									
										
										
										
											2007-10-21 09:32:18 +00:00
										 |  |  | 	int len = strlen(dir); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (len >= FILE_MAXDIR) /* path too long */ | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 	strcpy(name, dir); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 	if (len) { | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 		slash = strrchr(name, '/'); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		if (slash) slash[1] = 0; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-09 03:46:30 +00:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		strcpy(name, "/"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-07 13:39:00 +11:00
										 |  |  | #if  defined(USE_STATFS_STATVFS)
 | 
					
						
							|  |  |  | 	if (statvfs(name, &disk)) return -1; | 
					
						
							|  |  |  | #elif defined(USE_STATFS_4ARGS)
 | 
					
						
							|  |  |  | 	if (statfs(name, &disk, sizeof(struct statfs), 0)) return -1; | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 	if (statfs(name, &disk)) return -1; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ( ((double) disk.f_bsize) * ((double) disk.f_bfree)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | struct BuildDirCtx { | 
					
						
							|  |  |  | 	struct direntry *files; /* array[nrfiles] */ | 
					
						
							|  |  |  | 	int nrfiles; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Scans the directory named *dirname and appends entries for its contents to files. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-03-05 07:36:30 +00:00
										 |  |  | static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	struct ListBase dirbase = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2013-03-05 04:24:53 +00:00
										 |  |  | 	int newnum = 0; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	DIR *dir; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 04:24:53 +00:00
										 |  |  | 	if ((dir = opendir(dirname)) != NULL) { | 
					
						
							| 
									
										
										
										
											2013-03-05 07:36:30 +00:00
										 |  |  | 		const struct dirent *fname; | 
					
						
							|  |  |  | 		while ((fname = readdir(dir)) != NULL) { | 
					
						
							|  |  |  | 			struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink)); | 
					
						
							|  |  |  | 			if (dlink != NULL) { | 
					
						
							|  |  |  | 				dlink->name = BLI_strdup(fname->d_name); | 
					
						
							|  |  |  | 				BLI_addhead(&dirbase, dlink); | 
					
						
							|  |  |  | 				newnum++; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-03-05 04:24:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-27 10:35:39 +00:00
										 |  |  | 		if (newnum) { | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 			if (dir_ctx->files) { | 
					
						
							| 
									
										
										
										
											2015-02-15 15:04:28 +01:00
										 |  |  | 				void * const tmp = MEM_reallocN(dir_ctx->files, (dir_ctx->nrfiles + newnum) * sizeof(struct direntry)); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 				if (tmp) { | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 					dir_ctx->files = (struct direntry *)tmp; | 
					
						
							| 
									
										
										
										
											2010-08-11 22:36:43 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				else { /* realloc fail */ | 
					
						
							| 
									
										
										
										
											2015-02-15 15:04:28 +01:00
										 |  |  | 					MEM_freeN(dir_ctx->files); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 					dir_ctx->files = NULL; | 
					
						
							| 
									
										
										
										
											2010-08-11 22:36:43 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 			if (dir_ctx->files == NULL) | 
					
						
							| 
									
										
										
										
											2015-02-15 15:04:28 +01:00
										 |  |  | 				dir_ctx->files = (struct direntry *)MEM_mallocN(newnum * sizeof(struct direntry), __func__); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 			if (dir_ctx->files) { | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 				struct dirlink * dlink = (struct dirlink *) dirbase.first; | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 				struct direntry *file = &dir_ctx->files[dir_ctx->nrfiles]; | 
					
						
							| 
									
										
										
										
											2012-03-24 07:52:14 +00:00
										 |  |  | 				while (dlink) { | 
					
						
							| 
									
										
										
										
											2013-08-20 08:33:04 +00:00
										 |  |  | 					char fullname[PATH_MAX]; | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 					memset(file, 0, sizeof(struct direntry)); | 
					
						
							|  |  |  | 					file->relname = dlink->name; | 
					
						
							|  |  |  | 					file->path = BLI_strdupcat(dirname, dlink->name); | 
					
						
							| 
									
										
										
										
											2013-08-20 08:33:04 +00:00
										 |  |  | 					BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name); | 
					
						
							| 
									
										
										
										
											2014-06-23 10:07:06 +09:00
										 |  |  | 					BLI_stat(fullname, &file->s); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 					file->type = file->s.st_mode; | 
					
						
							|  |  |  | 					file->flags = 0; | 
					
						
							|  |  |  | 					dir_ctx->nrfiles++; | 
					
						
							|  |  |  | 					file++; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 					dlink = dlink->next; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 				printf("Couldn't get memory for dir\n"); | 
					
						
							|  |  |  | 				exit(1); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 			BLI_freelist(&dirbase); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 			if (dir_ctx->files) { | 
					
						
							|  |  |  | 				qsort(dir_ctx->files, dir_ctx->nrfiles, sizeof(struct direntry), (int (*)(const void *, const void *))bli_compare); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 			printf("%s empty directory\n", dirname); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		closedir(dir); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2014-11-03 23:26:43 +01:00
										 |  |  | 		printf("%s non-existent directory\n", dirname); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Fills in the "mode[123]", "size" and "string" fields in the elements of the files | 
					
						
							|  |  |  |  * array with descriptive details about each item. "string" will have a format similar to "ls -l". | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | static void bli_adddirstrings(struct BuildDirCtx *dir_ctx) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-09 06:26:46 +00:00
										 |  |  | 	const char *types[8] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"}; | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	/* symbolic display, indexed by mode field value */ | 
					
						
							| 
									
										
										
										
											2013-04-13 14:57:08 +00:00
										 |  |  | 	int num; | 
					
						
							| 
									
										
										
										
											2005-04-30 09:57:35 +00:00
										 |  |  | #ifdef WIN32
 | 
					
						
							|  |  |  | 	__int64 st_size; | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2008-02-17 18:09:53 +00:00
										 |  |  | 	off_t st_size; | 
					
						
							| 
									
										
										
										
											2013-04-13 14:57:08 +00:00
										 |  |  | 	int mode; | 
					
						
							| 
									
										
										
										
											2005-04-30 09:57:35 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	struct direntry *file; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	struct tm *tm; | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	time_t zero = 0; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 	for (num = 0, file = dir_ctx->files; num < dir_ctx->nrfiles; num++, file++) { | 
					
						
							| 
									
										
										
										
											2013-04-13 14:57:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* Mode */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #ifdef WIN32
 | 
					
						
							| 
									
										
										
										
											2011-10-19 23:10:54 +00:00
										 |  |  | 		BLI_strncpy(file->mode1, types[0], sizeof(file->mode1)); | 
					
						
							|  |  |  | 		BLI_strncpy(file->mode2, types[0], sizeof(file->mode2)); | 
					
						
							|  |  |  | 		BLI_strncpy(file->mode3, types[0], sizeof(file->mode3)); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 		mode = file->s.st_mode; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-19 23:10:54 +00:00
										 |  |  | 		BLI_strncpy(file->mode1, types[(mode & 0700) >> 6], sizeof(file->mode1)); | 
					
						
							|  |  |  | 		BLI_strncpy(file->mode2, types[(mode & 0070) >> 3], sizeof(file->mode2)); | 
					
						
							| 
									
										
										
										
											2013-03-09 06:26:46 +00:00
										 |  |  | 		BLI_strncpy(file->mode3, types[(mode & 0007)],      sizeof(file->mode3)); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		if (((mode & S_ISGID) == S_ISGID) && (file->mode2[2] == '-')) file->mode2[2] = 'l'; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-27 10:35:39 +00:00
										 |  |  | 		if (mode & (S_ISUID | S_ISGID)) { | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 			if (file->mode1[2] == 'x') file->mode1[2] = 's'; | 
					
						
							|  |  |  | 			else file->mode1[2] = 'S'; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 			if (file->mode2[2] == 'x') file->mode2[2] = 's'; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-27 10:35:39 +00:00
										 |  |  | 		if (mode & S_ISVTX) { | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 			if (file->mode3[2] == 'x') file->mode3[2] = 't'; | 
					
						
							|  |  |  | 			else file->mode3[2] = 'T'; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 14:57:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* User */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #ifdef WIN32
 | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 		strcpy(file->owner, "user"); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2005-03-29 16:43:39 +00:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			struct passwd *pwuser; | 
					
						
							| 
									
										
										
											
												* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
  by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
  Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
  /usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
  by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
  bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
											
										 
											2010-03-30 12:15:16 +00:00
										 |  |  | 			pwuser = getpwuid(file->s.st_uid); | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 			if (pwuser) { | 
					
						
							| 
									
										
										
											
												* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
  by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
  Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
  /usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
  by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
  bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
											
										 
											2010-03-30 12:15:16 +00:00
										 |  |  | 				BLI_strncpy(file->owner, pwuser->pw_name, sizeof(file->owner)); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2014-04-13 11:26:31 +10:00
										 |  |  | 				BLI_snprintf(file->owner, sizeof(file->owner), "%u", file->s.st_uid); | 
					
						
							| 
									
										
										
										
											2010-03-22 09:30:00 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2005-03-29 16:43:39 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 14:57:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* Time */ | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		tm = localtime(&file->s.st_mtime); | 
					
						
							| 
									
										
										
										
											2004-05-06 20:53:05 +00:00
										 |  |  | 		// prevent impossible dates in windows
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		if (tm == NULL) tm = localtime(&zero); | 
					
						
							| 
									
										
										
										
											2012-01-11 12:33:51 +00:00
										 |  |  | 		strftime(file->time, sizeof(file->time), "%H:%M", tm); | 
					
						
							|  |  |  | 		strftime(file->date, sizeof(file->date), "%d-%b-%y", tm); | 
					
						
							| 
									
										
										
										
											2004-05-06 20:53:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 14:57:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* Size */ | 
					
						
							| 
									
										
										
										
											2007-03-07 06:19:15 +00:00
										 |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * Seems st_size is signed 32-bit value in *nix and Windows.  This | 
					
						
							|  |  |  | 		 * will buy us some time until files get bigger than 4GB or until | 
					
						
							|  |  |  | 		 * everyone starts using __USE_FILE_OFFSET64 or equivalent. | 
					
						
							|  |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		st_size = file->s.st_size; | 
					
						
							| 
									
										
										
										
											2009-03-14 13:12:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		if (st_size > 1024 * 1024 * 1024) { | 
					
						
							| 
									
										
										
										
											2013-07-23 15:01:59 +00:00
										 |  |  | 			BLI_snprintf(file->size, sizeof(file->size), "%.2f GiB", ((double)st_size) / (1024 * 1024 * 1024)); | 
					
						
							| 
									
										
										
										
											2009-03-14 13:12:11 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		else if (st_size > 1024 * 1024) { | 
					
						
							| 
									
										
										
										
											2013-07-23 15:01:59 +00:00
										 |  |  | 			BLI_snprintf(file->size, sizeof(file->size), "%.1f MiB", ((double)st_size) / (1024 * 1024)); | 
					
						
							| 
									
										
										
										
											2009-03-14 13:12:11 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else if (st_size > 1024) { | 
					
						
							| 
									
										
										
										
											2013-07-23 15:01:59 +00:00
										 |  |  | 			BLI_snprintf(file->size, sizeof(file->size), "%d KiB", (int)(st_size / 1024)); | 
					
						
							| 
									
										
										
										
											2009-03-14 13:12:11 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-01-11 12:33:51 +00:00
										 |  |  | 			BLI_snprintf(file->size, sizeof(file->size), "%d B", (int)st_size); | 
					
						
							| 
									
										
										
										
											2009-03-14 13:12:11 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Scans the contents of the directory named *dirname, and allocates and fills in an | 
					
						
							| 
									
										
										
										
											2015-01-03 12:27:40 +01:00
										 |  |  |  * array of entries describing them in *filelist. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \return The length of filelist array. | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-01-03 12:27:40 +01:00
										 |  |  | unsigned int BLI_filelist_dir_contents(const char *dirname,  struct direntry **filelist) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 	struct BuildDirCtx dir_ctx; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 	dir_ctx.nrfiles = 0; | 
					
						
							|  |  |  | 	dir_ctx.files = NULL; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 07:36:30 +00:00
										 |  |  | 	bli_builddir(&dir_ctx, dirname); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 	bli_adddirstrings(&dir_ctx); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 	if (dir_ctx.files) { | 
					
						
							|  |  |  | 		*filelist = dir_ctx.files; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:18:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		// keep blender happy. Blender stores this in a variable
 | 
					
						
							|  |  |  | 		// where 0 has special meaning.....
 | 
					
						
							| 
									
										
										
										
											2015-02-15 15:04:28 +01:00
										 |  |  | 		*filelist = MEM_mallocN(sizeof(**filelist), __func__); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return dir_ctx.nrfiles; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-03 10:13:02 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Deep-duplicate of an array of direntries, including the array itself. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dup_poin If given, called for each non-NULL direntry->poin. Otherwise, pointer is always simply copied over. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void BLI_filelist_duplicate( | 
					
						
							|  |  |  |         struct direntry **dest_filelist, struct direntry *src_filelist, unsigned int nrentries, | 
					
						
							|  |  |  |         void *(*dup_poin)(void *)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	unsigned int i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-15 15:04:28 +01:00
										 |  |  | 	*dest_filelist = MEM_mallocN(sizeof(**dest_filelist) * (size_t)(nrentries), __func__); | 
					
						
							| 
									
										
										
										
											2015-01-03 10:13:02 +01:00
										 |  |  | 	for (i = 0; i < nrentries; ++i) { | 
					
						
							|  |  |  | 		struct direntry * const src = &src_filelist[i]; | 
					
						
							|  |  |  | 		struct direntry *dest = &(*dest_filelist)[i]; | 
					
						
							|  |  |  | 		*dest = *src; | 
					
						
							|  |  |  | 		if (dest->image) { | 
					
						
							|  |  |  | 			dest->image = IMB_dupImBuf(src->image); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (dest->relname) { | 
					
						
							|  |  |  | 			dest->relname = MEM_dupallocN(src->relname); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (dest->path) { | 
					
						
							|  |  |  | 			dest->path = MEM_dupallocN(src->path); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (dest->poin && dup_poin) { | 
					
						
							|  |  |  | 			dest->poin = dup_poin(src->poin); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * frees storage for an array of direntries, including the array itself. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-01-03 12:27:40 +01:00
										 |  |  | void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries, void (*free_poin)(void *)) | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	unsigned int i; | 
					
						
							| 
									
										
										
										
											2013-03-05 14:47:49 +00:00
										 |  |  | 	for (i = 0; i < nrentries; ++i) { | 
					
						
							| 
									
										
										
										
											2015-01-06 18:21:46 +11:00
										 |  |  | 		struct direntry *entry = filelist + i; | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 		if (entry->image) { | 
					
						
							|  |  |  | 			IMB_freeImBuf(entry->image); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (entry->relname) | 
					
						
							|  |  |  | 			MEM_freeN(entry->relname); | 
					
						
							|  |  |  | 		if (entry->path) | 
					
						
							|  |  |  | 			MEM_freeN(entry->path); | 
					
						
							| 
									
										
										
										
											2015-01-03 12:27:40 +01:00
										 |  |  | 		if (entry->poin && free_poin) | 
					
						
							|  |  |  | 			free_poin(entry->poin); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 15:50:12 +05:00
										 |  |  | 	if (filelist != NULL) { | 
					
						
							|  |  |  | 		MEM_freeN(filelist); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Returns the file size of an opened file descriptor. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-22 15:35:49 +00:00
										 |  |  | size_t BLI_file_descriptor_size(int file) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-05 04:11:55 +00:00
										 |  |  | 	struct stat st; | 
					
						
							|  |  |  | 	if ((file < 0) || (fstat(file, &st) == -1)) | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	return st.st_size; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Returns the size of a file. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-22 15:35:49 +00:00
										 |  |  | size_t BLI_file_size(const char *path) | 
					
						
							| 
									
										
										
										
											2008-01-21 22:10:20 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-28 22:50:40 +06:00
										 |  |  | 	BLI_stat_t stats; | 
					
						
							| 
									
										
										
										
											2013-03-05 04:11:55 +00:00
										 |  |  | 	if (BLI_stat(path, &stats) == -1) | 
					
						
							| 
									
										
										
										
											2008-01-21 22:10:20 +00:00
										 |  |  | 		return -1; | 
					
						
							| 
									
										
										
										
											2013-03-05 04:11:55 +00:00
										 |  |  | 	return stats.st_size; | 
					
						
							| 
									
										
										
										
											2008-01-21 22:10:20 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Returns the st_mode from statting the specified path name, or 0 if it couldn't be statted | 
					
						
							|  |  |  |  * (most likely doesn't exist or no access). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-21 22:33:41 +00:00
										 |  |  | int BLI_exists(const char *name) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | #if defined(WIN32) 
 | 
					
						
							| 
									
										
										
										
											2014-06-23 10:07:06 +09:00
										 |  |  | 	BLI_stat_t st; | 
					
						
							| 
									
										
										
										
											2014-04-21 16:49:35 +02:00
										 |  |  | 	wchar_t *tmp_16 = alloc_utf16_from_8(name, 1); | 
					
						
							| 
									
										
										
										
											2010-07-20 19:26:53 +00:00
										 |  |  | 	int len, res; | 
					
						
							| 
									
										
										
										
											2013-04-11 14:13:20 +00:00
										 |  |  | 	unsigned int old_error_mode; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 	len = wcslen(tmp_16); | 
					
						
							| 
									
										
										
										
											2014-04-21 16:49:35 +02:00
										 |  |  | 	/* in Windows #stat doesn't recognize dir ending on a slash
 | 
					
						
							|  |  |  | 	 * so we remove it here */ | 
					
						
							|  |  |  | 	if (len > 3 && (tmp_16[len - 1] == L'\\' || tmp_16[len - 1] == L'/')) { | 
					
						
							| 
									
										
										
										
											2013-04-11 14:13:20 +00:00
										 |  |  | 		tmp_16[len - 1] = '\0'; | 
					
						
							| 
									
										
										
										
											2014-04-21 16:49:35 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	/* two special cases where the trailing slash is needed:
 | 
					
						
							|  |  |  | 	 * 1. after the share part of a UNC path | 
					
						
							|  |  |  | 	 * 2. after the C:\ when the path is the volume only | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	if ((len >= 3) && (tmp_16[0] ==  L'\\') && (tmp_16[1] ==  L'\\')) { | 
					
						
							|  |  |  | 		BLI_cleanup_unc_16(tmp_16); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ((tmp_16[1] ==  L':') && (tmp_16[2] ==  L'\0')) { | 
					
						
							|  |  |  | 		tmp_16[2] = L'\\'; | 
					
						
							|  |  |  | 		tmp_16[3] = L'\0'; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-11 14:13:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* change error mode so user does not get a "no disk in drive" popup
 | 
					
						
							|  |  |  | 	 * when looking for a file on an empty CD/DVD drive */ | 
					
						
							| 
									
										
										
										
											2013-04-12 00:50:40 +00:00
										 |  |  | 	old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); | 
					
						
							| 
									
										
										
										
											2013-04-11 14:13:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-23 10:07:06 +09:00
										 |  |  | 	res = BLI_wstat(tmp_16, &st); | 
					
						
							| 
									
										
										
										
											2013-04-11 14:13:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	SetErrorMode(old_error_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 	free(tmp_16); | 
					
						
							|  |  |  | 	if (res == -1) return(0); | 
					
						
							| 
									
										
										
										
											2006-03-19 13:28:01 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2010-07-14 23:39:23 +00:00
										 |  |  | 	struct stat st; | 
					
						
							| 
									
										
										
										
											2015-02-17 11:31:04 +11:00
										 |  |  | 	BLI_assert(name); | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 	if (stat(name, &st)) return(0); | 
					
						
							| 
									
										
										
										
											2006-03-19 13:28:01 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	return(st.st_mode); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-01 21:46:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef WIN32
 | 
					
						
							| 
									
										
										
										
											2014-05-28 22:50:40 +06:00
										 |  |  | int BLI_stat(const char *path, BLI_stat_t *buffer) | 
					
						
							| 
									
										
										
										
											2012-05-01 21:46:55 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int r; | 
					
						
							|  |  |  | 	UTF16_ENCODE(path); | 
					
						
							| 
									
										
										
										
											2013-04-17 19:35:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-23 10:07:06 +09:00
										 |  |  | 	r = BLI_wstat(path_16, buffer); | 
					
						
							| 
									
										
										
										
											2013-04-17 19:35:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-01 21:46:55 +00:00
										 |  |  | 	UTF16_UN_ENCODE(path); | 
					
						
							|  |  |  | 	return r; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-06-23 10:07:06 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | int BLI_wstat(const wchar_t *path, BLI_stat_t *buffer) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-08-07 13:51:05 +02:00
										 |  |  | #if defined(_MSC_VER) || defined(__MINGW64__)
 | 
					
						
							| 
									
										
										
										
											2014-06-23 10:07:06 +09:00
										 |  |  | 	return _wstat64(path, buffer); | 
					
						
							|  |  |  | #elif defined(__MINGW32__)
 | 
					
						
							|  |  |  | 	return _wstati64(path, buffer); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 	return _wstat(path, buffer); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2012-05-01 21:46:55 +00:00
										 |  |  | #else
 | 
					
						
							|  |  |  | int BLI_stat(const char *path, struct stat *buffer) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return stat(path, buffer); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Does the specified path point to a directory? | 
					
						
							|  |  |  |  * \note Would be better in fileops.c except that it needs stat.h so add here | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | bool BLI_is_dir(const char *file) | 
					
						
							| 
									
										
										
										
											2011-09-28 05:53:40 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-10-21 22:33:41 +00:00
										 |  |  | 	return S_ISDIR(BLI_exists(file)); | 
					
						
							| 
									
										
										
										
											2009-10-16 10:22:11 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Does the specified path point to a non-directory? | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | bool BLI_is_file(const char *path) | 
					
						
							| 
									
										
										
										
											2011-12-12 18:06:36 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	const int mode = BLI_exists(path); | 
					
						
							| 
									
										
										
										
											2011-12-12 18:06:36 +00:00
										 |  |  | 	return (mode && !S_ISDIR(mode)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Reads the contents of a text file and returns the lines in a linked list. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-22 15:35:49 +00:00
										 |  |  | LinkNode *BLI_file_read_as_lines(const char *name) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	FILE *fp = BLI_fopen(name, "r"); | 
					
						
							|  |  |  | 	LinkNode *lines = NULL; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	char *buf; | 
					
						
							| 
									
										
										
										
											2011-09-25 12:33:51 +00:00
										 |  |  | 	size_t size; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (!fp) return NULL; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 	fseek(fp, 0, SEEK_END); | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	size = (size_t)ftell(fp); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	fseek(fp, 0, SEEK_SET); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	buf = MEM_mallocN(size, "file_as_lines"); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	if (buf) { | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		size_t i, last = 0; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * size = because on win32 reading | 
					
						
							|  |  |  | 		 * all the bytes in the file will return | 
					
						
							|  |  |  | 		 * less bytes because of crnl changes. | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		size = fread(buf, 1, size, fp); | 
					
						
							|  |  |  | 		for (i = 0; i <= size; i++) { | 
					
						
							|  |  |  | 			if (i == size || buf[i] == '\n') { | 
					
						
							|  |  |  | 				char *line = BLI_strdupn(&buf[last], i - last); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				BLI_linklist_prepend(&lines, line); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 				/* faster to build singly-linked list in reverse order */ | 
					
						
							|  |  |  | 				/* alternatively, could process buffer in reverse order so
 | 
					
						
							|  |  |  | 				 * list ends up right way round to start with */ | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 				last = i + 1; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2010-02-08 13:55:31 +00:00
										 |  |  | 		MEM_freeN(buf); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	fclose(fp); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* get them the right way round */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	BLI_linklist_reverse(&lines); | 
					
						
							|  |  |  | 	return lines; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Frees memory from a previous call to BLI_file_read_as_lines. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-22 15:35:49 +00:00
										 |  |  | void BLI_file_free_lines(LinkNode *lines) | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-14 19:40:42 +00:00
										 |  |  | 	BLI_linklist_freeN(lines); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | } | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-16 15:13:21 +00:00
										 |  |  | /** is file1 older then file2 */ | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | bool BLI_file_older(const char *file1, const char *file2) | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-12 02:15:33 +00:00
										 |  |  | #ifdef WIN32
 | 
					
						
							| 
									
										
										
										
											2013-04-25 16:35:57 +00:00
										 |  |  | #ifndef __MINGW32__
 | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 	struct _stat st1, st2; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:35:57 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2013-04-17 19:35:33 +00:00
										 |  |  | 	struct _stati64 st1, st2; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:35:57 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-12 02:15:33 +00:00
										 |  |  | 	UTF16_ENCODE(file1); | 
					
						
							|  |  |  | 	UTF16_ENCODE(file2); | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-04-25 16:35:57 +00:00
										 |  |  | #ifndef __MINGW32__
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	if (_wstat(file1_16, &st1)) return false; | 
					
						
							|  |  |  | 	if (_wstat(file2_16, &st2)) return false; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:35:57 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2013-04-17 19:35:33 +00:00
										 |  |  | 	if (_wstati64(file1_16, &st1)) return false; | 
					
						
							|  |  |  | 	if (_wstati64(file2_16, &st2)) return false; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:35:57 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-04-17 19:35:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-12 02:15:33 +00:00
										 |  |  | 	UTF16_UN_ENCODE(file2); | 
					
						
							|  |  |  | 	UTF16_UN_ENCODE(file1); | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  | 	struct stat st1, st2; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	if (stat(file1, &st1)) return false; | 
					
						
							|  |  |  | 	if (stat(file2, &st2)) return false; | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  | 	return (st1.st_mtime < st2.st_mtime); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |