file_access.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program 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
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __PJ_FILE_ACCESS_H__
  20. #define __PJ_FILE_ACCESS_H__
  21. /**
  22. * @file file_access.h
  23. * @brief File manipulation and access.
  24. */
  25. #include <pj/types.h>
  26. PJ_BEGIN_DECL
  27. /**
  28. * @defgroup PJ_FILE_ACCESS File Access
  29. * @ingroup PJ_IO
  30. * @{
  31. *
  32. */
  33. /**
  34. * This structure describes file information, to be obtained by
  35. * calling #pj_file_getstat(). The time information in this structure
  36. * is in local time.
  37. */
  38. typedef struct pj_file_stat
  39. {
  40. pj_off_t size; /**< Total file size. */
  41. pj_time_val atime; /**< Time of last access. */
  42. pj_time_val mtime; /**< Time of last modification. */
  43. pj_time_val ctime; /**< Time of last creation. */
  44. } pj_file_stat;
  45. /**
  46. * Returns non-zero if the specified file exists.
  47. *
  48. * @param filename The file name.
  49. *
  50. * @return Non-zero if the file exists.
  51. */
  52. PJ_DECL(pj_bool_t) pj_file_exists(const char *filename);
  53. /**
  54. * Returns the size of the file.
  55. *
  56. * @param filename The file name.
  57. *
  58. * @return The file size in bytes or -1 on error.
  59. */
  60. PJ_DECL(pj_off_t) pj_file_size(const char *filename);
  61. /**
  62. * Delete a file.
  63. *
  64. * @param filename The filename.
  65. *
  66. * @return PJ_SUCCESS on success or the appropriate error code.
  67. */
  68. PJ_DECL(pj_status_t) pj_file_delete(const char *filename);
  69. /**
  70. * Move a \c oldname to \c newname. If \c newname already exists,
  71. * it will be overwritten.
  72. *
  73. * @param oldname The file to rename.
  74. * @param newname New filename to assign.
  75. *
  76. * @return PJ_SUCCESS on success or the appropriate error code.
  77. */
  78. PJ_DECL(pj_status_t) pj_file_move( const char *oldname,
  79. const char *newname);
  80. /**
  81. * Return information about the specified file. The time information in
  82. * the \c stat structure will be in local time.
  83. *
  84. * @param filename The filename.
  85. * @param stat Pointer to variable to receive file information.
  86. *
  87. * @return PJ_SUCCESS on success or the appropriate error code.
  88. */
  89. PJ_DECL(pj_status_t) pj_file_getstat(const char *filename, pj_file_stat *stat);
  90. /** @} */
  91. PJ_END_DECL
  92. #endif /* __PJ_FILE_ACCESS_H__ */