You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

129 lines
3.8 KiB

  1. /* gfileutils.h - File utility functions
  2. *
  3. * Copyright 2000 Red Hat, Inc.
  4. *
  5. * GLib is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU Lesser General Public License as
  7. * published by the Free Software Foundation; either version 2 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * GLib is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with GLib; see the file COPYING.LIB. If not,
  17. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. * Boston, MA 02111-1307, USA.
  19. */
  20. #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  21. #error "Only <glib.h> can be included directly."
  22. #endif
  23. #ifndef __G_FILEUTILS_H__
  24. #define __G_FILEUTILS_H__
  25. #include <glib/gerror.h>
  26. G_BEGIN_DECLS
  27. #define G_FILE_ERROR g_file_error_quark ()
  28. typedef enum
  29. {
  30. G_FILE_ERROR_EXIST,
  31. G_FILE_ERROR_ISDIR,
  32. G_FILE_ERROR_ACCES,
  33. G_FILE_ERROR_NAMETOOLONG,
  34. G_FILE_ERROR_NOENT,
  35. G_FILE_ERROR_NOTDIR,
  36. G_FILE_ERROR_NXIO,
  37. G_FILE_ERROR_NODEV,
  38. G_FILE_ERROR_ROFS,
  39. G_FILE_ERROR_TXTBSY,
  40. G_FILE_ERROR_FAULT,
  41. G_FILE_ERROR_LOOP,
  42. G_FILE_ERROR_NOSPC,
  43. G_FILE_ERROR_NOMEM,
  44. G_FILE_ERROR_MFILE,
  45. G_FILE_ERROR_NFILE,
  46. G_FILE_ERROR_BADF,
  47. G_FILE_ERROR_INVAL,
  48. G_FILE_ERROR_PIPE,
  49. G_FILE_ERROR_AGAIN,
  50. G_FILE_ERROR_INTR,
  51. G_FILE_ERROR_IO,
  52. G_FILE_ERROR_PERM,
  53. G_FILE_ERROR_NOSYS,
  54. G_FILE_ERROR_FAILED
  55. } GFileError;
  56. /* For backward-compat reasons, these are synced to an old
  57. * anonymous enum in libgnome. But don't use that enum
  58. * in new code.
  59. */
  60. typedef enum
  61. {
  62. G_FILE_TEST_IS_REGULAR = 1 << 0,
  63. G_FILE_TEST_IS_SYMLINK = 1 << 1,
  64. G_FILE_TEST_IS_DIR = 1 << 2,
  65. G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
  66. G_FILE_TEST_EXISTS = 1 << 4
  67. } GFileTest;
  68. GQuark g_file_error_quark (void);
  69. /* So other code can generate a GFileError */
  70. GFileError g_file_error_from_errno (gint err_no);
  71. #ifdef G_OS_WIN32
  72. #define g_file_test g_file_test_utf8
  73. #define g_file_get_contents g_file_get_contents_utf8
  74. #define g_mkstemp g_mkstemp_utf8
  75. #define g_file_open_tmp g_file_open_tmp_utf8
  76. #endif
  77. gboolean g_file_test (const gchar *filename,
  78. GFileTest test);
  79. gboolean g_file_get_contents (const gchar *filename,
  80. gchar **contents,
  81. gsize *length,
  82. GError **error);
  83. gboolean g_file_set_contents (const gchar *filename,
  84. const gchar *contents,
  85. gssize length,
  86. GError **error);
  87. gchar *g_file_read_link (const gchar *filename,
  88. GError **error);
  89. /* Wrapper / workalike for mkstemp() */
  90. gint g_mkstemp (gchar *tmpl);
  91. gint g_mkstemp_full (gchar *tmpl,
  92. int flags,
  93. int mode);
  94. /* Wrapper for g_mkstemp */
  95. gint g_file_open_tmp (const gchar *tmpl,
  96. gchar **name_used,
  97. GError **error);
  98. char *g_format_size_for_display (goffset size);
  99. gchar *g_build_path (const gchar *separator,
  100. const gchar *first_element,
  101. ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
  102. gchar *g_build_pathv (const gchar *separator,
  103. gchar **args) G_GNUC_MALLOC;
  104. gchar *g_build_filename (const gchar *first_element,
  105. ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
  106. gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC;
  107. int g_mkdir_with_parents (const gchar *pathname,
  108. int mode);
  109. G_END_DECLS
  110. #endif /* __G_FILEUTILS_H__ */