2011-02-18 13:58:08 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +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-01-07 19:13:47 +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-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2011-02-18 13:58:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file BLI_fileops.h
|
|
|
|
* \ingroup bli
|
2011-10-22 15:35:49 +00:00
|
|
|
* \brief File and directory operations.
|
2002-10-12 11:37:38 +00:00
|
|
|
* */
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLI_FILEOPS_H__
|
|
|
|
#define __BLI_FILEOPS_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-03-20 02:17:37 +00:00
|
|
|
#include <stdio.h>
|
2013-03-05 03:44:47 +00:00
|
|
|
#include <sys/stat.h>
|
2012-03-20 02:17:37 +00:00
|
|
|
|
2010-10-06 16:23:52 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-10-22 15:35:49 +00:00
|
|
|
/* for size_t (needed on windows) */
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2013-08-20 08:33:04 +00:00
|
|
|
#include <limits.h> /* for PATH_MAX */
|
|
|
|
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
# define PATH_MAX 4096
|
|
|
|
#endif
|
|
|
|
|
2012-03-20 03:48:32 +00:00
|
|
|
struct gzFile;
|
|
|
|
|
2011-10-22 15:35:49 +00:00
|
|
|
/* Common */
|
|
|
|
|
|
|
|
int BLI_exists(const char *path);
|
|
|
|
int BLI_copy(const char *path, const char *to);
|
|
|
|
int BLI_rename(const char *from, const char *to);
|
2013-03-05 03:53:22 +00:00
|
|
|
int BLI_delete(const char *path, bool dir, bool recursive);
|
2011-10-22 15:35:49 +00:00
|
|
|
int BLI_move(const char *path, const char *to);
|
|
|
|
int BLI_create_symlink(const char *path, const char *to);
|
2014-05-28 22:50:40 +06:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
# ifndef __MINGW64__
|
|
|
|
typedef struct _stat64 BLI_stat_t;
|
|
|
|
# else
|
|
|
|
typedef struct stat BLI_stat_t;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
typedef struct stat BLI_stat_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int BLI_stat(const char *path, BLI_stat_t *buffer);
|
2011-10-22 15:35:49 +00:00
|
|
|
|
|
|
|
/* Directories */
|
|
|
|
|
|
|
|
struct direntry;
|
|
|
|
|
2013-03-05 03:17:46 +00:00
|
|
|
bool BLI_is_dir(const char *path);
|
|
|
|
bool BLI_is_file(const char *path);
|
2011-10-22 15:35:49 +00:00
|
|
|
void BLI_dir_create_recursive(const char *dir);
|
|
|
|
double BLI_dir_free_space(const char *dir);
|
2012-07-01 22:19:19 +00:00
|
|
|
char *BLI_current_working_dir(char *dir, const size_t maxlen);
|
2011-10-22 15:35:49 +00:00
|
|
|
|
|
|
|
unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist);
|
2013-03-26 07:29:01 +00:00
|
|
|
void BLI_free_filelist(struct direntry *filelist, unsigned int nrentries);
|
2011-10-22 15:35:49 +00:00
|
|
|
|
|
|
|
/* Files */
|
|
|
|
|
2012-03-20 03:48:32 +00:00
|
|
|
FILE *BLI_fopen(const char *filename, const char *mode);
|
|
|
|
void *BLI_gzopen(const char *filename, const char *mode);
|
2012-03-20 02:17:37 +00:00
|
|
|
int BLI_open(const char *filename, int oflag, int pmode);
|
2013-03-13 19:48:07 +00:00
|
|
|
int BLI_access(const char *filename, int mode);
|
2012-03-20 02:17:37 +00:00
|
|
|
|
2013-03-05 03:53:22 +00:00
|
|
|
bool BLI_file_is_writable(const char *file);
|
|
|
|
bool BLI_file_touch(const char *file);
|
2011-10-22 15:35:49 +00:00
|
|
|
|
|
|
|
int BLI_file_gzip(const char *from, const char *to);
|
2014-03-16 03:24:05 +11:00
|
|
|
char *BLI_file_ungzip_to_mem(const char *from_file, int *r_size);
|
2011-10-22 15:35:49 +00:00
|
|
|
|
|
|
|
size_t BLI_file_descriptor_size(int file);
|
|
|
|
size_t BLI_file_size(const char *file);
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/* compare if one was last modified before the other */
|
2013-03-05 03:17:46 +00:00
|
|
|
bool BLI_file_older(const char *file1, const char *file2);
|
2011-10-22 15:35:49 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/* read ascii file as lines, empty list if reading fails */
|
2011-10-22 15:35:49 +00:00
|
|
|
struct LinkNode *BLI_file_read_as_lines(const char *file);
|
|
|
|
void BLI_file_free_lines(struct LinkNode *lines);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-09-03 10:12:25 +00:00
|
|
|
/* this weirdo pops up in two places ... */
|
|
|
|
#if !defined(WIN32)
|
|
|
|
# ifndef O_BINARY
|
|
|
|
# define O_BINARY 0
|
|
|
|
# endif
|
2012-10-06 07:03:03 +00:00
|
|
|
#else
|
|
|
|
void BLI_get_short_name(char short_name[256], const char *filename);
|
2012-09-03 10:12:25 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-06 16:23:52 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-05 03:53:22 +00:00
|
|
|
#endif /* __BLI_FILEOPS_H__ */
|