home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Inside Multimedia 1995 July
/
IMM0795.ISO
/
share
/
tools
/
freeman
/
disk1
/
fpath.h_
/
fpath
Wrap
Text File
|
1995-02-01
|
5KB
|
256 lines
#define __FPATH_H
#ifndef __IO_H
#include "io.h"
#endif
#ifndef __DOS_H
#include "dos.h"
#endif
#ifndef __STRING_H
#include "string.h"
#endif
#ifndef __DSTRING_H
#include "dstring.h"
#endif
#undef enable /* we don't need the macro enable & disable in dos.h */
#undef disable
#ifdef _MSC_VER /* microsoft */
#undef isborland
#else /* borland */
#define isborland
#endif
#ifdef isborland
typedef find_t ffbuf;
enum
{
ffarch = FA_ARCH,
ffdirec = FA_DIREC,
ffhidden = FA_HIDDEN,
ffsystem = FA_SYSTEM,
ffrdonly = FA_RDONLY,
ffnormal = FA_NORMAL
};
#else
typedef _find_t ffbuf;
enum
{
ffarch = _A_ARCH,
ffdirec = _A_SUBDIR,
ffhidden = _A_HIDDEN,
ffsystem = _A_SYSTEM,
ffrdonly = _A_RDONLY,
ffnormal = _A_NORMAL
};
/* MS didn't define ftime. we copy borland's io.h */
struct ftime
{
unsigned ft_tsec : 5; /* Two second interval */
unsigned ft_min : 6; /* Minutes */
unsigned ft_hour : 5; /* Hours */
unsigned ft_day : 5; /* Days */
unsigned ft_month : 4; /* Months */
unsigned ft_year : 7; /* Year */
};
#endif
typedef unsigned int UINT;
class varpath;
class abspath /* abstract path */
{
public:
enum
{
maxpath = 128, maxdrive = 4, maxdir = 128, maxfile = 15, maxext = 5
};
virtual char *getbuf() = 0;
operator char*()
{
return getbuf();
}
char operator[](int i)
{
return getbuf()[i];
}
int del();
int chdir();
int mkdir();
int rmdir();
int chkdll();
int chsize(long l);
int access(int amode);
int rename(abspath &x);
int chkroot();
int chkexist();
int chkcanwrite();
int chkdiroccupied();
int multimkdir();
int getdad(varpath *dad);
int getd(varpath *d);
int getf(varpath *f);
int tostd(varpath *path);
int gettime(ftime *ft);
int settime(ftime &ft);
int chksame(abspath &x);
int comparetime(abspath &y);
int setfileattr(UINT flags);
int getfileattr(UINT *flags);
int findfirst(int flags, ffbuf *b);
int findnext(ffbuf *b);
void get(char path[]);
void getf(char f[]);
long getsize();
long locatestr(char s[]);
#ifdef isborland
static struct find_t fs;
#else
static struct _find_t fs;
#endif
static int gethftime(int h, ftime *ft);
static int sethftime(int h, ftime &ft);
};
class conpath;
class varpath:public abspath /* variable path */
{
public:
virtual int set(char b[]) = 0;
int tostd()
{
return abspath::tostd(this);
}
int setcwd();
int gethome();
int setroot(int drv);
int setdirwin();
int setdirsys();
int merge(char d[], char f[]);
int merge(abspath &d, abspath &f);
int rplfile(char f[]);
int rplfile(abspath &f);
int setlastc(char c);
int tmpindir(abspath &d, char prefix[]);
int tmpinsamedir(abspath &path, char prefix[]);
};
class dynpath:public varpath /* variable path with dynamic buf */
{
dstring s;
public:
dynpath()
{
}
dynpath(char b[])
{
set(b);
}
int set(char b[])
{
return s.set(b);
}
int set(int n)
{
return s.set(n);
}
int getlen()
{
return s.getlen();
}
char *getbuf()
{
return s;
}
};
class borpath:public varpath /* variable path with borrowed buf */
{
char *s; /* the buffer must be large enough */
public:
borpath(char sx[])
{
s = sx;
}
int set(char b[])
{
strcpy(s, b);
return 1;
}
char *getbuf()
{
return s;
}
};
class stcpath:public varpath /* variable path with static buf */
{
char s[maxpath];
public:
stcpath()
{
s[0] = '\0';
}
stcpath(char b[])
{
set(b);
}
int set(char b[])
{
strcpy(s, b);
return 1;
}
char *getbuf()
{
return s;
}
};
class conpath:public abspath /* constant (invariable) path */
{
char *s;
public:
conpath(char b[])
{
s = b;
}
char *getbuf()
{
return s;
}
};