home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Linux
/
Enlightenment
/
enl_DR-0.10.tar.gz
/
enl_DR-0.10.tar
/
enl
/
file.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-06-19
|
1KB
|
101 lines
#include "enlightenment.h"
void md(char *s)
{
mkdir(s,S_IRWXU);
}
int exists(char *s)
{
struct stat st;
if (stat(s,&st)==-1) return 0;
return 1;
}
int isfile(char *s)
{
struct stat st;
if (stat(s,&st)==-1) return 0;
if (S_ISREG(st.st_mode)) return 1;
return 0;
}
int isdir(char *s)
{
struct stat st;
if (stat(s,&st)==-1) return 0;
if (S_ISDIR(st.st_mode)) return 1;
return 0;
}
char **ls(char *d, int *num)
{
struct dirent **dir;
int n;
char **l;
int i;
n=scandir(d,&dir,0,alphasort);
if (n<0)
{
*num=0;
return NULL;
}
else
{
l=malloc(sizeof(char *)*n);
for (i=0;i<n;i++)
{
l[i]=malloc(strlen(dir[i]->d_name)+1);
strcpy(l[i],dir[i]->d_name);
}
}
return l;
}
void rmls(char **l, int num)
{
while(num--) free(l[num]);
free(l);
}
void rm(char *s)
{
unlink(s);
}
void mv(char *s, char *ss)
{
rename(s,ss);
}
time_t moddate(char *s)
{
struct stat st;
if (!stat(s,&st)) return 0;
if (st.st_mtime>st.st_ctime) return st.st_mtime;
else return st.st_ctime;
}
int filesize(char *s)
{
struct stat st;
if (!stat(s,&st)) return 0;
return (int)st.st_size;
}
void cd(char *s)
{
chdir(s);
}
char *cwd(void)
{
return getcwd(NULL,-1);
}