2008-02-20 18:45:20 -06:00
|
|
|
/*
|
|
|
|
* mooutils-file.h
|
|
|
|
*
|
2010-11-07 01:20:45 -08:00
|
|
|
* Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@sourceforge.net>
|
2008-02-20 18:45:20 -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.
|
2008-02-20 18:45:20 -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/>.
|
2008-02-20 18:45:20 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOO_UTILS_FILE_H
|
|
|
|
#define MOO_UTILS_FILE_H
|
|
|
|
|
2010-11-23 19:07:27 -08:00
|
|
|
#include <mooutils/moofileloc.h>
|
2008-09-15 03:59:22 -05:00
|
|
|
#include <gio/gio.h>
|
2008-02-20 18:45:20 -06:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
2008-08-31 14:53:08 -05:00
|
|
|
typedef struct MooFileReader MooFileReader;
|
|
|
|
|
|
|
|
MooFileReader *moo_file_reader_new (const char *filename,
|
|
|
|
GError **error);
|
|
|
|
MooFileReader *moo_text_reader_new (const char *filename,
|
|
|
|
GError **error);
|
|
|
|
gboolean moo_file_reader_read (MooFileReader *reader,
|
|
|
|
char *buf,
|
|
|
|
gsize buf_size,
|
|
|
|
gsize *size_read,
|
|
|
|
GError **error);
|
|
|
|
void moo_file_reader_close (MooFileReader *reader);
|
|
|
|
|
2008-02-20 18:45:20 -06:00
|
|
|
typedef struct MooFileWriter MooFileWriter;
|
|
|
|
|
2008-09-13 22:46:03 -05:00
|
|
|
typedef enum /*< flags >*/
|
|
|
|
{
|
|
|
|
MOO_FILE_WRITER_SAVE_BACKUP = 1 << 0,
|
2010-01-18 23:58:33 -08:00
|
|
|
MOO_FILE_WRITER_CONFIG_MODE = 1 << 1,
|
|
|
|
MOO_FILE_WRITER_TEXT_MODE = 1 << 2
|
2008-09-13 22:46:03 -05:00
|
|
|
} MooFileWriterFlags;
|
|
|
|
|
2008-02-20 18:45:20 -06:00
|
|
|
MooFileWriter *moo_file_writer_new (const char *filename,
|
2008-09-13 22:46:03 -05:00
|
|
|
MooFileWriterFlags flags,
|
2008-02-20 18:45:20 -06:00
|
|
|
GError **error);
|
2008-09-15 03:59:22 -05:00
|
|
|
MooFileWriter *moo_file_writer_new_for_file (GFile *file,
|
|
|
|
MooFileWriterFlags flags,
|
|
|
|
GError **error);
|
2008-09-13 22:46:03 -05:00
|
|
|
MooFileWriter *moo_config_writer_new (const char *filename,
|
2008-02-20 18:45:20 -06:00
|
|
|
gboolean save_backup,
|
|
|
|
GError **error);
|
|
|
|
MooFileWriter *moo_string_writer_new (void);
|
|
|
|
|
|
|
|
gboolean moo_file_writer_write (MooFileWriter *writer,
|
|
|
|
const char *data,
|
|
|
|
gssize len);
|
|
|
|
gboolean moo_file_writer_printf (MooFileWriter *writer,
|
|
|
|
const char *fmt,
|
|
|
|
...) G_GNUC_PRINTF (2, 3);
|
|
|
|
gboolean moo_file_writer_close (MooFileWriter *writer,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
const char *moo_string_writer_get_string (MooFileWriter *writer,
|
|
|
|
gsize *len);
|
|
|
|
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* MOO_UTILS_FILE_H */
|