summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-09-30 16:17:28 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-09-30 16:17:28 (GMT)
commit5763cd3970d32d646f7a798a69196e70743375b5 (patch)
tree732565f7f728328ab17f33b8eca0ea237eb4e8b8 /generic
parent1f9a56de2f17443d6639279abb1b25b536c14cfc (diff)
downloadtcl-5763cd3970d32d646f7a798a69196e70743375b5.zip
tcl-5763cd3970d32d646f7a798a69196e70743375b5.tar.gz
tcl-5763cd3970d32d646f7a798a69196e70743375b5.tar.bz2
Start on tests and fixes for file commands for zipfs
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIOUtil.c24
-rw-r--r--generic/tclZipfs.c21
2 files changed, 34 insertions, 11 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index f665e0f..7bbb9cd 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -2281,11 +2281,17 @@ Tcl_FSUtime(
* times to use. Should not be modified. */
{
const Tcl_Filesystem *fsPtr = Tcl_FSGetFileSystemForPath(pathPtr);
+ int err;
- if (fsPtr != NULL && fsPtr->utimeProc != NULL) {
- return fsPtr->utimeProc(pathPtr, tval);
+ if (fsPtr == NULL) {
+ err = ENOENT;
+ } else {
+ if (fsPtr->utimeProc != NULL) {
+ return fsPtr->utimeProc(pathPtr, tval);
+ }
+ err = ENOTSUP;
}
- /* TODO: set errno here? Tcl_SetErrno(ENOENT); */
+ Tcl_SetErrno(err);
return -1;
}
@@ -4340,11 +4346,17 @@ Tcl_FSCreateDirectory(
Tcl_Obj *pathPtr) /* Pathname of directory to create (UTF-8). */
{
const Tcl_Filesystem *fsPtr = Tcl_FSGetFileSystemForPath(pathPtr);
+ int err;
- if (fsPtr != NULL && fsPtr->createDirectoryProc != NULL) {
- return fsPtr->createDirectoryProc(pathPtr);
+ if (fsPtr == NULL) {
+ err = ENOENT;
+ } else {
+ if (fsPtr->createDirectoryProc != NULL) {
+ return fsPtr->createDirectoryProc(pathPtr);
+ }
+ err = ENOTSUP;
}
- Tcl_SetErrno(ENOENT);
+ Tcl_SetErrno(err);
return -1;
}
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 0cc46a0..23b3f3c 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -1937,6 +1937,9 @@ ZipFSCatalogFilesystem(
if (!strcmp(z->name, ZIPFS_VOLUME)) {
z->flags |= ZE_F_VOLUME; /* Mark as root volume */
}
+ Tcl_Time t;
+ Tcl_GetTime(&t);
+ z->timestamp = t.sec;
z->next = zf->entries;
zf->entries = z;
}
@@ -4696,11 +4699,13 @@ ZipChannelOpen(
WriteLock();
z = ZipFSLookup(filename);
if (!z) {
- Tcl_SetErrno(ENOENT);
+ Tcl_SetErrno(wr ? ENOTSUP : ENOENT);
if (interp) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "file not found \"%s\": %s", filename,
- Tcl_PosixError(interp)));
+ Tcl_SetObjResult(interp,
+ Tcl_ObjPrintf("file \"%s\" not %s: %s",
+ filename,
+ wr ? "created" : "found",
+ Tcl_PosixError(interp)));
}
goto error;
}
@@ -5187,7 +5192,7 @@ ZipEntryStat(
Tcl_StatBuf *buf)
{
ZipEntry *z;
- int ret = -1;
+ int ret;
ReadLock();
z = ZipFSLookup(path);
@@ -5206,8 +5211,14 @@ ZipEntryStat(
} else if (ContainsMountPoint(path, -1)) {
/* An intermediate dir under which a mount exists */
memset(buf, 0, sizeof(Tcl_StatBuf));
+ Tcl_Time t;
+ Tcl_GetTime(&t);
+ buf->st_atime = buf->st_mtime = buf->st_ctime = t.sec;
buf->st_mode = S_IFDIR | 0555;
ret = 0;
+ } else {
+ Tcl_SetErrno(ENOENT);
+ ret = -1;
}
Unlock();
return ret;