47 return getenv(
"HOME");
68 if (stat(fn, &st) == -1) {
73 if ((st.st_mode & S_IFDIR) && (canthave &
SFF_SUBDIR))
76 if ((musthave &
SFF_SUBDIR) && !(st.st_mode & S_IFDIR))
87char*
Sys_FindFirst (
const char* path,
unsigned musthave,
unsigned canhave)
95 if ((p = strrchr(
findbase,
'/')) !=
nullptr) {
107 const struct dirent* d;
108 while ((d = readdir(
fdir)) !=
nullptr) {
130 const struct dirent* d;
131 while ((d = readdir(
fdir)) !=
nullptr) {
149#define MAX_FOUND_FILES 0x1000
155 if (subdirs[0] !=
'\0') {
156 Com_sprintf(search,
sizeof(search),
"%s/%s", basedir, subdirs);
158 Com_sprintf(search,
sizeof(search),
"%s", basedir);
162 if ((directory = opendir(search)) ==
nullptr)
166 const struct dirent* d;
169 while ((d = readdir(directory)) !=
nullptr) {
174 if (st.st_mode & S_IFDIR) {
177 if (subdirs[0] !=
'\0') {
178 Com_sprintf(newsubdirs,
sizeof(newsubdirs),
"%s/%s", subdirs, d->d_name);
180 Com_sprintf(newsubdirs,
sizeof(newsubdirs),
"%s", d->d_name);
201 if (getcwd(cwd,
sizeof(cwd) - 1) ==
nullptr)
210 if (mkdir(thePath, 0777) != -1)
214 Com_Printf(
"\"mkdir %s\" failed, reason: \"%s\".", thePath, strerror(errno));
222 if (!stat(ospath, &
buf) && S_ISFIFO(
buf.st_mode))
225 const int result = mkfifo(ospath, 0600);
231 const int fn = fileno(fifo);
232 fcntl(fn, F_SETFL, O_NONBLOCK);
235 Com_Printf(
"WARNING: Could not create fifo pipe at %s.\n", ospath);
252 return rename(oldname, newname);
void Com_Printf(const char *const fmt,...)
definitions common between client and server, but not game lib
void FS_RemoveFile(const char *osPath)
void Sys_Error(const char *error,...)
void LIST_AddString(linkedList_t **listDest, const char *data)
Adds an string to a new or to an already existing linked list. The string is copied here.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
#define Q_strcasecmp(a, b)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
int Com_Filter(const char *pattern, const char *text)
Match the pattern PATTERN against the string TEXT;.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
static char findbase[MAX_OSPATH]
char * Sys_FindFirst(const char *path, unsigned musthave, unsigned canhave)
Opens the directory and returns the first file that matches our searchrules.
void Sys_NormPath(char *path)
FILE * Sys_Fopen(const char *filename, const char *mode)
static char findpath[MAX_OSPATH]
int Sys_Remove(const char *filename)
int Sys_Rename(const char *oldname, const char *newname)
char * Sys_GetHomeDirectory(void)
Returns the home environment variable (which hold the path of the user's homedir).
void Sys_ListFilteredFiles(const char *basedir, const char *subdirs, const char *filter, linkedList_t **list)
static bool CompareAttributes(const char *path, const char *name, unsigned musthave, unsigned canthave)
void Sys_Mkfifo(const char *ospath, qFILE *f)
static char findpattern[MAX_OSPATH]
void Sys_Mkdir(const char *thePath)
char * Sys_FindNext(unsigned musthave, unsigned canhave)
Returns the next file of the already opened directory (Sys_FindFirst) that matches our search mask.
int Sys_Access(const char *filename, int mode)