| 
									
										
										
										
											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
 | 
					
						
							|  |  |  | #include <dirent.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <time.h>
 | 
					
						
							|  |  |  | #include <sys/stat.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | #if defined(__sun__) || defined(__sun) || defined(__NetBSD__)
 | 
					
						
							| 
									
										
										
										
											2008-01-26 20:36:14 +00:00
										 |  |  | #include <sys/statvfs.h> /* Other modern unix os's should probably use this also */
 | 
					
						
							| 
									
										
										
										
											2008-12-14 17:32:24 +00:00
										 |  |  | #elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__))
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #include <sys/statfs.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | #if defined(__FreeBSD__) || defined(__OpenBSD__)
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #include <sys/param.h>
 | 
					
						
							|  |  |  | #include <sys/mount.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-26 00:13:03 +00:00
										 |  |  | #if defined(linux) || defined(__CYGWIN32__) || defined(__hpux) || defined(__GNU__) || defined(__GLIBC__)
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #include <sys/vfs.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __APPLE__
 | 
					
						
							|  |  |  | /* For statfs */ | 
					
						
							|  |  |  | #include <sys/param.h>
 | 
					
						
							|  |  |  | #include <sys/mount.h>
 | 
					
						
							|  |  |  | #endif /* __APPLE__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #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 */ | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	if (strcmp(entry1->relname, ".") == 0) return (-1); | 
					
						
							|  |  |  | 	if (strcmp(entry2->relname, ".") == 0) return (1); | 
					
						
							|  |  |  | 	if (strcmp(entry1->relname, "..") == 0) return (-1); | 
					
						
							|  |  |  | 	if (strcmp(entry2->relname, "..") == 0) 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | #if defined(__sun__) || defined(__sun) || defined(__NetBSD__)
 | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 	else strcpy(name, "/"); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | #if defined(__FreeBSD__) || defined(linux) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__GNU__) || defined(__GLIBC__)
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	if (statfs(name, &disk)) return(-1); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | #if defined(__sun__) || defined(__sun) || defined(__NetBSD__)
 | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 	if (statvfs(name, &disk)) return(-1); | 
					
						
							| 
									
										
										
										
											2008-12-14 17:32:24 +00:00
										 |  |  | #elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__))
 | 
					
						
							| 
									
										
										
										
											2008-01-26 20:36:14 +00:00
										 |  |  | 	/* WARNING - This may not be supported by geeneric unix os's - Campbell */ | 
					
						
							|  |  |  | 	if (statfs(name, &disk, sizeof(struct statfs), 0)) 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. | 
					
						
							|  |  |  |  * Recorded pathnames will be prefixed by *relname if specified (FIXME: actually this | 
					
						
							|  |  |  |  * option is not used anywhere, might as well get rid of it). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | static void bli_builddir(const char *dirname, const char *relname, | 
					
						
							|  |  |  |                          struct BuildDirCtx *dir_ctx) | 
					
						
							| 
									
										
										
										
											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) { | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 04:24:53 +00:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			const struct dirent *fname; | 
					
						
							|  |  |  | 			int rellen; | 
					
						
							|  |  |  | 			char buf[PATH_MAX]; | 
					
						
							|  |  |  | 			BLI_strncpy(buf, relname, sizeof(buf)); | 
					
						
							|  |  |  | 			rellen = strlen(relname); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 04:24:53 +00:00
										 |  |  | 			if (rellen) { | 
					
						
							|  |  |  | 				buf[rellen] = '/'; | 
					
						
							|  |  |  | 				rellen++; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			while ((fname = readdir(dir)) != NULL) { | 
					
						
							|  |  |  | 				struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink)); | 
					
						
							|  |  |  | 				if (dlink != NULL) { | 
					
						
							|  |  |  | 					BLI_strncpy(buf + rellen, fname->d_name, sizeof(buf) - rellen); | 
					
						
							|  |  |  | 					dlink->name = BLI_strdup(buf); | 
					
						
							|  |  |  | 					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) { | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 			if (dir_ctx->files) { | 
					
						
							|  |  |  | 				void * const tmp = realloc(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 */ | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 					free(dir_ctx->files); | 
					
						
							|  |  |  | 					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) | 
					
						
							|  |  |  | 				dir_ctx->files = (struct direntry *)malloc(newnum * sizeof(struct direntry)); | 
					
						
							| 
									
										
										
										
											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-03-05 04:24:53 +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-03-05 06:26:10 +00:00
										 |  |  | 					BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name); | 
					
						
							| 
									
										
										
										
											2009-07-26 12:49:43 +00:00
										 |  |  | // use 64 bit file size, only needed for WIN32 and WIN64. 
 | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | // Excluding other than current MSVC compiler until able to test
 | 
					
						
							|  |  |  | #ifdef WIN32
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 					{ | 
					
						
							| 
									
										
										
										
											2013-03-05 04:24:53 +00:00
										 |  |  | 						wchar_t *name_16 = alloc_utf16_from_8(fullname, 0); | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | #if (defined(WIN32) || defined(WIN64)) && (_MSC_VER >= 1500)
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 						_wstat64(name_16, &entry->s); | 
					
						
							| 
									
										
										
										
											2010-07-26 10:41:26 +00:00
										 |  |  | #elif defined(__MINGW32__)
 | 
					
						
							| 
									
										
										
										
											2013-03-05 04:24:53 +00:00
										 |  |  | 						_stati64(fullname, &entry->s); | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 						free(name_16); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-26 12:40:44 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2013-03-05 04:24:53 +00:00
										 |  |  | 					stat(fullname, &file->s); | 
					
						
							| 
									
										
										
										
											2009-07-26 12:40:44 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											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 { | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 		printf("%s non-existant 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
										 |  |  | { | 
					
						
							|  |  |  | 	char datum[100]; | 
					
						
							| 
									
										
										
										
											2009-06-08 20:08:19 +00:00
										 |  |  | 	char buf[512]; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	char size[250]; | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	static 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 */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	int num, mode; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											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++) { | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #ifdef WIN32
 | 
					
						
							|  |  |  | 		mode = 0; | 
					
						
							| 
									
										
										
										
											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)); | 
					
						
							|  |  |  | 		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
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #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 { | 
					
						
							| 
									
										
										
										
											2011-08-30 10:07:50 +00:00
										 |  |  | 				BLI_snprintf(file->owner, sizeof(file->owner), "%d", 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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 		/* FIXME: Either change decimal prefixes to binary ones
 | 
					
						
							|  |  |  | 		 * <http://en.wikipedia.org/wiki/Binary_prefix>, or change
 | 
					
						
							|  |  |  | 		 * divisor factors from 1024 to 1000. */ | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 		if (st_size > 1024 * 1024 * 1024) { | 
					
						
							|  |  |  | 			BLI_snprintf(file->size, sizeof(file->size), "%.2f GB", ((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) { | 
					
						
							|  |  |  | 			BLI_snprintf(file->size, sizeof(file->size), "%.1f MB", ((double)st_size) / (1024 * 1024)); | 
					
						
							| 
									
										
										
										
											2009-03-14 13:12:11 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else if (st_size > 1024) { | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 			BLI_snprintf(file->size, sizeof(file->size), "%d KB", (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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-11 12:33:51 +00:00
										 |  |  | 		strftime(datum, 32, "%d-%b-%y %H:%M", tm); /* XXX, is this used? - campbell */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (st_size < 1000) { | 
					
						
							| 
									
										
										
										
											2012-01-11 12:33:51 +00:00
										 |  |  | 			BLI_snprintf(size, sizeof(size), "%10d", | 
					
						
							|  |  |  | 			             (int) st_size); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (st_size < 1000 * 1000) { | 
					
						
							|  |  |  | 			BLI_snprintf(size, sizeof(size), "%6d %03d", | 
					
						
							|  |  |  | 			             (int) (st_size / 1000), (int) (st_size % 1000)); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (st_size < 100 * 1000 * 1000) { | 
					
						
							|  |  |  | 			BLI_snprintf(size, sizeof(size), "%2d %03d %03d", | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 			             (int) (st_size / (1000 * 1000)), (int) ((st_size / 1000) % 1000), (int) (st_size % 1000)); | 
					
						
							| 
									
										
										
										
											2012-01-11 12:33:51 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			/* XXX, whats going on here?. 2x calls - campbell */ | 
					
						
							|  |  |  | 			BLI_snprintf(size, sizeof(size), "> %4.1f M", (double) (st_size / (1024.0 * 1024.0))); | 
					
						
							|  |  |  | 			BLI_snprintf(size, sizeof(size), "%10d", (int) st_size); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-11 12:33:51 +00:00
										 |  |  | 		BLI_snprintf(buf, sizeof(buf), "%s %s %s %7s %s %s %10s %s", | 
					
						
							|  |  |  | 		             file->mode1, file->mode2, file->mode3, file->owner, | 
					
						
							|  |  |  | 		             file->date, file->time, size, file->relname); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-11 12:33:51 +00:00
										 |  |  | 		file->string = BLI_strdup(buf); | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 		/* FIXME: not actually used anywhere, why bother to set it up? */ | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  |  * array of entries describing them in *filelist. The length of the array is the function result. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-22 15:35:49 +00:00
										 |  |  | unsigned int BLI_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 03:44:47 +00:00
										 |  |  | 	bli_builddir(dirname, "", &dir_ctx); | 
					
						
							|  |  |  | 	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.....
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 		*filelist = malloc(sizeof(struct direntry)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return dir_ctx.nrfiles; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* frees storage for an array of direntries, including the array itself. */ | 
					
						
							|  |  |  | void BLI_free_filelist(struct direntry *filelist, unsigned int nrentries) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	unsigned int i; | 
					
						
							|  |  |  | 	for (i = 0; i < nrentries; ++i) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		struct direntry * const entry = filelist + i; | 
					
						
							|  |  |  | 		if (entry->image) { | 
					
						
							|  |  |  | 			IMB_freeImBuf(entry->image); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (entry->relname) | 
					
						
							|  |  |  | 			MEM_freeN(entry->relname); | 
					
						
							|  |  |  | 		if (entry->path) | 
					
						
							|  |  |  | 			MEM_freeN(entry->path); | 
					
						
							|  |  |  | 		if (entry->string) | 
					
						
							|  |  |  | 			MEM_freeN(entry->string); | 
					
						
							|  |  |  | 		/* entry->poin assumed not to point to anything needing freeing here */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:44:47 +00:00
										 |  |  | 	free(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
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-05 04:11:55 +00:00
										 |  |  | 	struct stat stats; | 
					
						
							|  |  |  | 	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) 
 | 
					
						
							|  |  |  | #ifndef __MINGW32__
 | 
					
						
							| 
									
										
										
										
											2010-07-14 23:39:23 +00:00
										 |  |  | 	struct _stat64i32 st; | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2010-07-26 10:41:26 +00:00
										 |  |  | 	struct _stati64 st; | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	/* in Windows stat doesn't recognize dir ending on a slash
 | 
					
						
							|  |  |  | 	 * To not break code where the ending slash is expected we | 
					
						
							|  |  |  | 	 * don't mess with the argument name directly here - elubie */ | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	wchar_t *tmp_16 = alloc_utf16_from_8(name, 0); | 
					
						
							| 
									
										
										
										
											2010-07-20 19:26:53 +00:00
										 |  |  | 	int len, res; | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 	len = wcslen(tmp_16); | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	if (len > 3 && (tmp_16[len - 1] == L'\\' || tmp_16[len - 1] == L'/') ) tmp_16[len - 1] = '\0'; | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | #ifndef __MINGW32__
 | 
					
						
							|  |  |  | 	res = _wstat(tmp_16, &st); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 	res = _wstati64(tmp_16, &st); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	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; | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							|  |  |  | int BLI_stat(const char *path, struct stat *buffer) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int r; | 
					
						
							|  |  |  | 	UTF16_ENCODE(path); | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	r = _wstat(path_16, buffer); | 
					
						
							| 
									
										
										
										
											2012-05-01 21:46:55 +00:00
										 |  |  | 	UTF16_UN_ENCODE(path); | 
					
						
							|  |  |  | 	return r; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #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
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-12 15:02:10 +00:00
										 |  |  | 	BLI_linklist_free(lines, (void (*)(void *))MEM_freeN); | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 	struct _stat st1, st2; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-12 02:15:33 +00:00
										 |  |  | 	UTF16_ENCODE(file1); | 
					
						
							|  |  |  | 	UTF16_ENCODE(file2); | 
					
						
							| 
									
										
										
										
											2012-03-20 02:17:37 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-03-05 03:17:46 +00:00
										 |  |  | 	if (_wstat(file1_16, &st1)) return false; | 
					
						
							|  |  |  | 	if (_wstat(file2_16, &st2)) return false; | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |