FileUtil.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * File: FileUtil.h $XConsortium: FileUtil.h /main/4 1995/10/26 15:21:50 rswiston $
  25. * Language: C
  26. *
  27. * (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
  28. *
  29. * (c) Copyright 1993, 1994 Hewlett-Packard Company *
  30. * (c) Copyright 1993, 1994 International Business Machines Corp. *
  31. * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
  32. * (c) Copyright 1993, 1994 Novell, Inc. *
  33. */
  34. #ifndef _FileUtil_h
  35. #define _FileUtil_h
  36. extern int _DtCreateDirs( char *path,
  37. int mode) ;
  38. /******************
  39. *
  40. * Function Name: _DtCreateDirs
  41. *
  42. * Description:
  43. *
  44. * This function is passed a directory path to create and the mode
  45. * for the directory. It will create any of the parent directories
  46. * on the path that do not already exist.
  47. *
  48. * This function may fail if any of the directories on the path already
  49. * exist and are not writable. If some component of the path already
  50. * exists and is not a directory, a failure will be returned.
  51. *
  52. * If some component of the path exists as a directory but does not have
  53. * the specified mode, this will NOT cause a failure to be returned.
  54. * This implies that if this function is called to create a writeable
  55. * directory, it is possible for the function to return successfully
  56. * but the directory may not actually be writable.
  57. *
  58. * Synopsis:
  59. *
  60. * status = _DtCreateDirs (path, mode);
  61. *
  62. * int status; Returns 0 on success and -1 on failure.
  63. * char *path; The directory path to create.
  64. * int mode; The file mode for setting any directories
  65. * that are created.
  66. *
  67. ******************/
  68. extern int _DtIsOpenableDir( char *path) ;
  69. /******************
  70. *
  71. * Function Name: _DtIsOpenableDir
  72. *
  73. * Description:
  74. *
  75. * This function takes a path as an argument and determines whether
  76. * the path is a directory that can be opened. This function returns
  77. * "1" if the path is an openable directory and "0" if it is not.
  78. *
  79. * The path can be in the Softbench "context" form of "host:/path/dir".
  80. *
  81. * Synopsis:
  82. *
  83. * status = _DtIsOpenableDir (cpath)
  84. *
  85. * int status; Returns 1 for openable directories,
  86. * 0 otherwise.
  87. * char *cpath; The directory name to test.
  88. *
  89. ******************/
  90. extern int
  91. _DtIsOpenableDirContext(
  92. char *path,
  93. char **ret_path ) ;
  94. /******************
  95. *
  96. * Function Name: _DtIsOpenableDirContext
  97. *
  98. * Description:
  99. *
  100. * This function takes a path as an argument and determines whether
  101. * the path is a directory that can be opened. This function returns
  102. * "1" if the path is an openable directory and "0" if it is not.
  103. * In addition, if the calling function passes in another pointer,
  104. * we will return the internal representation for the path.
  105. *
  106. * The path can be in the Softbench "context" form of "host:/path/dir".
  107. *
  108. * Synopsis:
  109. *
  110. * status = _DtIsOpenableDirContext (cpath, ret_ptr)
  111. *
  112. * int status; Returns 1 for openable directories,
  113. * 0 otherwise.
  114. * char *cpath; The directory name to test.
  115. * char ** ret_ptr; Where to place internal format.
  116. *
  117. ******************/
  118. extern char * _DtReaddirLstat(
  119. char *dir_name,
  120. DIR *dirp,
  121. struct stat *st_buf) ;
  122. /******************
  123. *
  124. * Function Name: _DtReaddirLstat
  125. *
  126. * Description:
  127. *
  128. * This function reads the next entry out of a directory that has
  129. * been opened with opendir and returns lstat information on it.
  130. * For more information on reading a directory, see directory(3C).
  131. * For more information on lstat information, see stat(2).
  132. *
  133. * This function returns a pointer to the full pathname of the directory
  134. * entry. This memory is owned by this function and must not be
  135. * freed. If the caller wants to keep the filename, it must make its
  136. * own copy. When the end of the directory is encountered, NULL is
  137. * returned.
  138. *
  139. * Synopsis:
  140. *
  141. * dir_entry = _DtReaddirLstat (dir_name, dirp, st_buf);
  142. *
  143. * char *dir_entry; The name of the current entry within the
  144. * directory.
  145. *
  146. * char *dir_name; The full path name of the directory.
  147. *
  148. * DIR *dirp; A pointer to the directory [obtained from
  149. * opendir(3C)].
  150. *
  151. * struct stat *st_buf; The lstat(2) information.
  152. *
  153. ******************/
  154. #endif /* _FileUtil_h */
  155. /* DON'T ADD ANYTHING AFTER THIS #endif */