2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
gb_file_share.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2017-01-13 04:29:42 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01: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
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GB_FILE_H
|
|
|
|
#define __GB_FILE_H
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
|
|
|
|
#ifdef PROJECT_EXEC
|
|
|
|
|
2013-09-29 18:56:12 +02:00
|
|
|
#include "gambas.h"
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
typedef
|
2013-09-29 18:56:12 +02:00
|
|
|
GB_FILE_STAT FILE_STAT;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* Constants for Stat() function */
|
|
|
|
|
|
|
|
#define GB_STAT_FILE 1
|
|
|
|
#define GB_STAT_DIRECTORY 2
|
|
|
|
#define GB_STAT_DEVICE 3
|
|
|
|
#define GB_STAT_PIPE 4
|
|
|
|
#define GB_STAT_SOCKET 5
|
|
|
|
#define GB_STAT_LINK 6
|
|
|
|
|
|
|
|
#define GB_STAT_READ R_OK
|
|
|
|
#define GB_STAT_WRITE W_OK
|
|
|
|
#define GB_STAT_EXEC X_OK
|
|
|
|
|
|
|
|
#define GB_STAT_USER 0
|
|
|
|
#define GB_STAT_GROUP 1
|
|
|
|
#define GB_STAT_OTHER 2
|
|
|
|
|
|
|
|
#define FILE_TEMP_PREFIX "/tmp/gambas.%d"
|
|
|
|
#define FILE_TEMP_DIR "/tmp/gambas.%d/%d"
|
|
|
|
#define FILE_TEMP_FILE "/tmp/gambas.%d/%d/%d.tmp"
|
|
|
|
#define FILE_TEMP_PATTERN "/tmp/gambas.%d/%d/%s.tmp"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GBX_INFO
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
const char *FILE_cat(const char *path, ...);
|
|
|
|
char *FILE_buffer(void);
|
|
|
|
int FILE_buffer_length(void);
|
|
|
|
const char *FILE_get_dir(const char *path);
|
|
|
|
const char *FILE_get_name(const char *path);
|
|
|
|
const char *FILE_get_ext(const char *path);
|
|
|
|
const char *FILE_get_basename(const char *path);
|
2007-12-30 17:41:49 +01:00
|
|
|
/*PUBLIC const char *FILE_get(const char *path);*/
|
2009-07-08 21:57:50 +02:00
|
|
|
const char *FILE_set_ext(const char *path, const char *ext);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
const char *FILE_getcwd(const char *subdir);
|
2007-12-30 17:41:49 +01:00
|
|
|
#define FILE_get_current_dir() FILE_getcwd(NULL)
|
2010-10-31 23:05:29 +01:00
|
|
|
void FILE_chdir(const char *path);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
const char *FILE_readlink(const char *link);
|
|
|
|
bool FILE_is_dir(const char *path);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
const char *FILE_find_gambas(void);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2017-04-27 15:18:35 +02:00
|
|
|
void FILE_rename_ext(const char *src, const char *dst, bool unlink);
|
|
|
|
#define FILE_rename(_src, _dst) FILE_rename_ext(_src, _dst, FALSE)
|
|
|
|
#define FILE_rename_unlink(_src, _dst) FILE_rename_ext(_src, _dst, TRUE)
|
|
|
|
|
2011-03-29 02:24:15 +02:00
|
|
|
void FILE_unlink(const char *path);
|
|
|
|
|
2016-02-01 03:18:49 +01:00
|
|
|
char *FILE_get_home(void);
|
|
|
|
void FILE_exit(void);
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#ifdef PROJECT_EXEC
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void FILE_init(void);
|
|
|
|
void FILE_remove_temp_file(void);
|
2013-09-29 22:54:47 +02:00
|
|
|
void FILE_remove_temp_file_pid(pid_t pid);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-07-17 12:57:55 +02:00
|
|
|
bool FILE_exist_follow(const char *path, bool follow);
|
|
|
|
#define FILE_exist(_path) FILE_exist_follow(_path, FALSE)
|
2009-07-08 21:57:50 +02:00
|
|
|
bool FILE_exist_real(const char *path);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void FILE_stat(const char *path, FILE_STAT *info, bool follow);
|
|
|
|
void FILE_dir_first(const char *path, const char *pattern, int attr);
|
|
|
|
bool FILE_dir_next(char **path, int *len);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void FILE_rmdir(const char *path);
|
|
|
|
void FILE_mkdir(const char *path);
|
|
|
|
void FILE_copy(const char *src, const char *dst);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
bool FILE_access(const char *path, int mode);
|
|
|
|
void FILE_link(const char *src, const char *dst);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-01 19:45:35 +01:00
|
|
|
char *FILE_make_temp(int *len, const char *pattern);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-03-25 03:00:55 +01:00
|
|
|
void FILE_recursive_dir(const char *dir, void (*found)(const char *), void (*afterfound)(const char *), int attr, bool follow);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void FILE_make_path_dir(const char *path);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
int64_t FILE_free(const char *path);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-01-15 09:54:57 +01:00
|
|
|
char *FILE_mode_to_string(mode_t mode);
|
|
|
|
mode_t FILE_mode_from_string(mode_t mode, const char *str);
|
|
|
|
|
|
|
|
void FILE_chmod(const char *path, mode_t mode);
|
|
|
|
void FILE_chown(const char *path, const char *user);
|
|
|
|
void FILE_chgrp(const char *path, const char *group);
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#else
|
|
|
|
|
2011-07-17 12:57:55 +02:00
|
|
|
bool FILE_exist(const char *path);
|
2009-07-08 21:57:50 +02:00
|
|
|
time_t FILE_get_time(const char *path);
|
2013-03-31 07:51:47 +02:00
|
|
|
bool FILE_copy(const char *src, const char *dst);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-09-13 01:21:44 +02:00
|
|
|
#define FILE_is_absolute(_path) (*(_path) == '/' || * (_path) == '~')
|
|
|
|
#define FILE_is_relative(_path) (!FILE_is_absolute(_path))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|