mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Improve zipos path handling (#579)
This change adds opendir, readdir, and stat support for the /zip/ root, as well as directories not explicitly encoded in the zip file.
This commit is contained in:
parent
494d74271b
commit
1ef955c33b
5 changed files with 73 additions and 10 deletions
|
@ -64,6 +64,10 @@ TEST(stat, zipos) {
|
|||
stat("/zip/.python/test/"
|
||||
"tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt",
|
||||
&st));
|
||||
EXPECT_SYS(0, 0, stat("/zip", &st));
|
||||
EXPECT_SYS(0, 0, stat("/zip/", &st));
|
||||
EXPECT_SYS(0, 0, stat("/zip/.python", &st));
|
||||
EXPECT_SYS(0, 0, stat("/zip/.python/", &st));
|
||||
}
|
||||
|
||||
static long Stat(const char *path, struct stat *st) {
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/dt.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
@ -57,6 +57,35 @@ TEST(opendir, enotdir) {
|
|||
ASSERT_SYS(ENOTDIR, NULL, opendir("yo/there"));
|
||||
}
|
||||
|
||||
TEST(opendir, zipTest_fake) {
|
||||
ASSERT_NE(NULL, (dir = opendir("/zip")));
|
||||
EXPECT_NE(NULL, (ent = readdir(dir)));
|
||||
EXPECT_STREQ("echo", ent->d_name);
|
||||
EXPECT_NE(NULL, (ent = readdir(dir)));
|
||||
EXPECT_STREQ("usr", ent->d_name);
|
||||
EXPECT_EQ(NULL, (ent = readdir(dir)));
|
||||
EXPECT_EQ(0, closedir(dir));
|
||||
ASSERT_NE(NULL, (dir = opendir("/zip/")));
|
||||
EXPECT_NE(NULL, (ent = readdir(dir)));
|
||||
EXPECT_STREQ("echo", ent->d_name);
|
||||
EXPECT_NE(NULL, (ent = readdir(dir)));
|
||||
EXPECT_STREQ("usr", ent->d_name);
|
||||
EXPECT_EQ(NULL, (ent = readdir(dir)));
|
||||
EXPECT_EQ(0, closedir(dir));
|
||||
ASSERT_NE(NULL, (dir = opendir("/zip/usr")));
|
||||
EXPECT_NE(NULL, (ent = readdir(dir)));
|
||||
EXPECT_STREQ("share", ent->d_name);
|
||||
EXPECT_EQ(NULL, (ent = readdir(dir)));
|
||||
EXPECT_EQ(0, closedir(dir));
|
||||
ASSERT_NE(NULL, (dir = opendir("/zip/usr/")));
|
||||
EXPECT_NE(NULL, (ent = readdir(dir)));
|
||||
EXPECT_STREQ("share", ent->d_name);
|
||||
EXPECT_EQ(NULL, (ent = readdir(dir)));
|
||||
EXPECT_EQ(0, closedir(dir));
|
||||
EXPECT_EQ(NULL, (dir = opendir("/zip/us")));
|
||||
EXPECT_EQ(NULL, (dir = opendir("/zip/us/")));
|
||||
}
|
||||
|
||||
TEST(dirstream, testDots) {
|
||||
int hasdot = 0;
|
||||
int hasdotdot = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue