10 #include "wvdiriter.h"
26 return mkdir(_dir, create_mode);
32 if (!access(_dir, X_OK))
41 while ((p = strchr(++p,
'/')))
44 if (access(dir, X_OK) && wvmkdir(dir, create_mode))
51 return (access(dir, X_OK&W_OK) && wvmkdir(dir, create_mode)) ? -1 : 0;
58 for (i.rewind(); i.next(); )
63 ::unlink(i->fullname);
79 int oldmode = umask(0);
80 WvFile out(dst, O_CREAT|O_WRONLY, buf.st_mode & 007777);
84 while (in.isok() && out.isok())
90 if (in.select(-1,
true,
false))
97 utim.actime = utim.modtime = buf.st_mtime;
98 if (utime(dst, &utim))
107 return fcopy(
WvString(
"%s/%s", srcdir, relname),
108 WvString(
"%s/%s", dstdir, relname));
114 if (!
WvFile(file, O_WRONLY|O_CREAT).isok())
117 struct utimbuf *buf = NULL;
120 buf = (
struct utimbuf *)malloc(
sizeof(
struct utimbuf));
121 buf->actime = time(NULL);
122 buf->modtime = mtime;
125 if (utime(file, buf) == 0)
140 return WvString::null;
146 result.setsize(size);
147 int readlink_result = readlink(path, result.
edit(), size);
148 if (readlink_result == -1)
149 return WvString::null;
150 if (readlink_result < size)
152 result.
edit()[readlink_result] =
'\0';
167 if (stat(file1, &buf) || stat(file2, &buf2))
170 if (buf.st_mtime == buf2.st_mtime || buf.st_ctime == buf2.st_ctime)
179 return samedate(
WvString(
"%s/%s", dir1, relname),
189 WvStringList::Iter i(patterns);
192 for (i.rewind(); i.next(); )
202 if (i->cstr()[0] ==
'!')
206 if (fnmatch(*i+1, name, flags) == 0)
212 if (fnmatch(*i, name, flags) == 0)
222 int wvchmod(
const char *path, mode_t mode)
225 if (lstat(path, &st) == -1) {
229 int filedes = open(path, O_RDONLY);
240 if (stat(path, &sst) != -1)
241 if (st.st_ino == sst.st_ino)
242 return chmod(path, mode);
248 if (fstat(filedes, &fst) == -1) {
253 if (st.st_ino != fst.st_ino) {
262 int retval = fchmod(filedes, mode);
267 int retval = chmod(path, mode);
283 char *name = _tempnam(
"c:\\temp",
"wvtmp");
284 FILE *f = fopen(name,
"wb+");
294 WvString tmpname(
"/tmp/%sXXXXXX", prefix);
296 if ((fd = mkstemp(tmpname.edit())) == (-1))
302 fd = open(tmpname, O_WRONLY|O_CREAT|O_EXCL, 0777);
304 return WvString::null;
314 mode_t rv = umask(0);
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
const char * cstr() const
return a (const char *) for this string.
WvFile implements a stream connected to a file or Unix device.
This is a WvList of WvStrings, and is a really handy way to parse strings.
WvString is an implementation of a simple and efficient printable-string class.
char * edit()
make the string editable, and return a non-const (char*)