1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
/*
Disk IO, Directory Listing, and Path Parsing/Manipulations
*/
#ifndef DISK_H
#define DISK_H
#include <sys/stat.h>
#include <sys/types.h>
#include "os.h"
/* MSW makeups. */
#ifdef __MSW__
# include <direct.h>
# define mode_t unsigned short
# define S_ISDIR(m) ((m) & S_IFDIR)
# define S_ISREG(m) ((m) & S_IFREG)
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Path deliminator. */
#ifndef DIR_DELIMINATOR
# ifdef __MSW__
# define DIR_DELIMINATOR '\\'
# else
# define DIR_DELIMINATOR '/'
# endif
#endif
extern int FILEHASEXTENSION(const char *filename);
extern int ISPATHABSOLUTE(const char *path);
extern int NUMDIRCONTENTS(const char *path);
extern int COMPARE_PARENT_PATHS(const char *path, const char *parent);
extern int ISPATHDIR(const char *path);
extern int ISLPATHDIR(const char *path);
extern int ISPATHEXECUTABLE(const char *path);
extern int rmkdir(const char *path, mode_t m);
extern char *PathSubHome(const char *path);
extern char **GetDirEntNames2(const char *parent, int *total);
extern char **GetDirEntNames(const char *parent);
extern char *ChangeDirRel(const char *cpath, const char *npath);
extern void StripAbsolutePath(char *path);
extern void StripParentPath(char *path, const char *parent);
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" char *PrefixPaths(const char *parent, const char *child);
#else
extern char *PrefixPaths(const char *parent, const char *child);
#endif
extern char *GetAllocLinkDest(const char *link);
extern char *GetParentDir(const char *path);
#define COMPLETE_PATH_SUCCESS 0
#define COMPLETE_PATH_NONE -1
#define COMPLETE_PATH_AMBIGUOUS -2
#define COMPLETE_PATH_PARTIAL -3
extern char *CompletePath(char *path, int *status);
extern int FileCountLines(const char *filename);
extern int DirHasSubDirs(const char *path);
extern void StripPath(char *path);
extern void SimplifyPath(char *path);
extern int CopyObject(
const char *target, const char *source,
int (*comferm_func)(const char *, const char *)
);
#ifdef __MSW__
/*
* Windows path notation delimiters.
*/
# define PATH_SEP_CHAR '\\'
# define PATH_SEP_STR "\\"
# define CWD_STR ".\\"
#else
# define PATH_SEP_CHAR '/'
# define PATH_SEP_STR "/"
# define CWD_STR "./"
#endif /* __WIN32__ */
#ifdef __cplusplus
}
#endif
#endif /* DISK_H */
|