2006-03-16 04:39:35 -06:00
|
|
|
/*
|
|
|
|
* mooutils-fs.h
|
|
|
|
*
|
2010-12-21 20:15:45 -08:00
|
|
|
* Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@users.sourceforge.net>
|
2006-03-16 04:39:35 -06:00
|
|
|
*
|
2008-09-05 17:20:50 -05:00
|
|
|
* This file is part of medit. medit is free software; you can
|
|
|
|
* redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2.1 of the License,
|
|
|
|
* or (at your option) any later version.
|
2006-03-16 04:39:35 -06:00
|
|
|
*
|
2008-09-05 17:20:50 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
2006-03-16 04:39:35 -06:00
|
|
|
*/
|
|
|
|
|
2007-04-12 10:31:28 -05:00
|
|
|
#ifndef MOO_UTILS_FS_H
|
|
|
|
#define MOO_UTILS_FS_H
|
2006-03-16 04:39:35 -06:00
|
|
|
|
|
|
|
#include <glib.h>
|
2011-09-26 00:41:51 -07:00
|
|
|
#include <gtk/gtk.h>
|
2006-03-16 04:39:35 -06:00
|
|
|
|
2006-06-13 01:29:27 -05:00
|
|
|
/* MSVC */
|
2013-04-20 22:14:56 -07:00
|
|
|
#if defined(_WIN32) && !defined(__GNUC__)
|
2006-06-13 03:01:35 -05:00
|
|
|
#include <sys/stat.h>
|
2013-04-20 22:14:56 -07:00
|
|
|
#include <fcntl.h>
|
2006-06-13 03:01:35 -05:00
|
|
|
#ifndef S_ISREG
|
2006-06-13 01:29:27 -05:00
|
|
|
#define S_ISREG(m) (((m) & (_S_IFMT)) == (_S_IFREG))
|
|
|
|
#define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
|
|
|
|
#endif
|
2006-06-13 03:01:35 -05:00
|
|
|
#endif
|
2006-06-13 01:29:27 -05:00
|
|
|
|
2008-05-21 15:37:44 -05:00
|
|
|
#ifndef O_BINARY
|
|
|
|
#define O_BINARY 0x0
|
|
|
|
#endif
|
|
|
|
|
2006-03-16 04:39:35 -06:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
2006-08-01 20:28:28 -05:00
|
|
|
#define MOO_FILE_ERROR (_moo_file_error_quark ())
|
2006-04-16 12:14:12 -05:00
|
|
|
|
2007-02-09 20:28:28 -06:00
|
|
|
/* XXX */
|
|
|
|
#define _moo_save_file_utf8 moo_save_file_utf8
|
|
|
|
#define _moo_unlink moo_unlink
|
|
|
|
|
2006-04-16 12:14:12 -05:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
MOO_FILE_ERROR_NONEXISTENT,
|
|
|
|
MOO_FILE_ERROR_NOT_FOLDER,
|
|
|
|
MOO_FILE_ERROR_BAD_FILENAME,
|
|
|
|
MOO_FILE_ERROR_FAILED,
|
|
|
|
MOO_FILE_ERROR_ALREADY_EXISTS,
|
|
|
|
MOO_FILE_ERROR_ACCESS_DENIED,
|
|
|
|
MOO_FILE_ERROR_READONLY,
|
|
|
|
MOO_FILE_ERROR_DIFFERENT_FS,
|
|
|
|
MOO_FILE_ERROR_NOT_IMPLEMENTED
|
|
|
|
} MooFileError;
|
|
|
|
|
2006-08-01 20:28:28 -05:00
|
|
|
GQuark _moo_file_error_quark (void) G_GNUC_CONST;
|
|
|
|
MooFileError _moo_file_error_from_errno (int err_code);
|
2006-04-16 12:14:12 -05:00
|
|
|
|
2006-08-01 20:28:28 -05:00
|
|
|
gboolean _moo_save_file_utf8 (const char *name,
|
2006-03-16 04:39:35 -06:00
|
|
|
const char *text,
|
|
|
|
gssize len,
|
|
|
|
GError **error);
|
2006-11-03 23:57:57 -06:00
|
|
|
gboolean _moo_remove_dir (const char *path,
|
2006-04-16 12:14:12 -05:00
|
|
|
gboolean recursive,
|
|
|
|
GError **error);
|
2006-11-03 23:57:57 -06:00
|
|
|
gboolean _moo_create_dir (const char *path,
|
2006-04-09 04:01:14 -05:00
|
|
|
GError **error);
|
2007-06-10 03:39:26 -05:00
|
|
|
int _moo_mkdir_with_parents (const char *path); /* S_IRWXU on unix */
|
2006-11-03 23:57:57 -06:00
|
|
|
gboolean _moo_rename_file (const char *path,
|
2006-08-23 03:09:17 -05:00
|
|
|
const char *new_path,
|
|
|
|
GError **error);
|
2006-03-16 04:39:35 -06:00
|
|
|
|
2009-11-01 12:44:46 -08:00
|
|
|
char **moo_filenames_from_locale (char **files);
|
|
|
|
char *moo_filename_from_locale (const char *file);
|
|
|
|
char *_moo_filename_to_uri (const char *file,
|
2008-05-21 15:37:44 -05:00
|
|
|
GError **error);
|
2006-03-16 14:01:15 -06:00
|
|
|
|
2006-08-01 20:28:28 -05:00
|
|
|
char *_moo_normalize_file_path (const char *filename);
|
2008-01-27 00:07:18 -06:00
|
|
|
gboolean _moo_path_is_absolute (const char *path);
|
2006-08-01 20:18:35 -05:00
|
|
|
|
2009-11-01 12:44:46 -08:00
|
|
|
gboolean _moo_copy_files_ui (GList *filenames,
|
|
|
|
const char *destdir,
|
|
|
|
GtkWidget *parent);
|
|
|
|
gboolean _moo_move_files_ui (GList *filenames,
|
|
|
|
const char *destdir,
|
|
|
|
GtkWidget *parent);
|
|
|
|
|
2006-03-16 04:39:35 -06:00
|
|
|
/*
|
|
|
|
* C library and WinAPI functions wrappers analogous to glib/gstdio.h
|
|
|
|
*/
|
|
|
|
|
2006-11-03 23:57:57 -06:00
|
|
|
int _moo_unlink (const char *path);
|
|
|
|
int _moo_mkdir (const char *path); /* S_IRWXU on unix */
|
|
|
|
int _moo_remove (const char *path);
|
|
|
|
gpointer _moo_fopen (const char *path,
|
2006-03-16 04:39:35 -06:00
|
|
|
const char *mode);
|
2006-11-03 23:57:57 -06:00
|
|
|
int _moo_rename (const char *old_name,
|
2006-03-16 04:39:35 -06:00
|
|
|
const char *new_name);
|
|
|
|
|
2006-11-12 13:12:46 -06:00
|
|
|
gboolean _moo_glob_match_simple (const char *pattern,
|
|
|
|
const char *filename);
|
|
|
|
|
|
|
|
|
2006-03-16 04:39:35 -06:00
|
|
|
G_END_DECLS
|
|
|
|
|
2007-04-12 10:31:28 -05:00
|
|
|
#endif /* MOO_UTILS_FS_H */
|