Skip to content

Commit

Permalink
Add compression hint to the file API, solid files should be scanned d…
Browse files Browse the repository at this point in the history
…irectly.
  • Loading branch information
mywave82 committed Dec 24, 2023
1 parent a8780b3 commit 2da5283
Show file tree
Hide file tree
Showing 20 changed files with 134 additions and 43 deletions.
12 changes: 8 additions & 4 deletions filesel/cdfs/cdfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ OCP_INTERNAL struct cdfs_disc_t *cdfs_disc_new (struct ocpfile_t *file)
file->dirdb_ref,
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
file->compression);

file->parent->ref (file->parent);
disc->dirs[0]->owner = disc;
Expand Down Expand Up @@ -910,7 +911,8 @@ CDFS_Directory_add (struct cdfs_disc_t *self, const uint32_t dir_parent_handle,
dirdb_ref,
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
self->dirs[0]->head.compression);

self->dirs[self->dir_fill]->owner = self;
self->dirs[self->dir_fill]->dir_parent = dir_parent_handle;
Expand Down Expand Up @@ -976,7 +978,8 @@ CDFS_File_add (struct cdfs_disc_t *self,
0, /* filename_override */
dirdb_ref,
0, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
COMPRESSION_ADD_STORE(self->dirs[0]->head.compression));

self->files[self->file_fill]->owner = self;
self->files[self->file_fill]->dir_parent = dir_parent_handle;
Expand Down Expand Up @@ -1112,7 +1115,8 @@ CDFS_File_add_audio (struct cdfs_disc_t *self, const uint32_t dir_parent_handle,
cdfs_file_filename_override,
dirdb_ref,
0, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
COMPRESSION_ADD_STORE(self->dirs[0]->head.compression));

self->files[self->file_fill]->owner = self;
self->files[self->file_fill]->dir_parent = dir_parent_handle;
Expand Down
15 changes: 10 additions & 5 deletions filesel/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ static int cdint (const struct configAPI_t *configAPI)
dirdbFindAndRef (DIRDB_NOPARENT, "cdrom:", dirdb_use_dir),
0, /* we ignore refcounting */
0, /* not an archive */
0 /* not a playlist */);
0, /* not a playlist */
COMPRESSION_NONE);

dmCDROM=RegisterDrive("cdrom:", &cdrom_root, &cdrom_root);

Expand Down Expand Up @@ -464,7 +465,8 @@ static int cdrom_root_readdir_iterate (ocpdirhandle_pt _dh)
dirdbFindAndRef (dh->owner->dirdb_ref, cdroms[dh->n].vdev, dirdb_use_dir),
1,
0, /* not an archive */
0 /* not a playlist */);
0, /* not a playlist */
COMPRESSION_NONE);

dir->cdrom = cdroms + dh->n;
dh->owner->ref (dh->owner);
Expand Down Expand Up @@ -529,7 +531,8 @@ static struct ocpdir_t *cdrom_root_readdir_dir (struct ocpdir_t *_self, uint32_t
dirdbRef (dirdb_ref, dirdb_use_dir),
1,
0, /* not an archive */
0 /* not a playlist */);
0, /* not a playlist */
COMPRESSION_NONE);

return &dir->head;
}
Expand Down Expand Up @@ -790,7 +793,8 @@ static int cdrom_drive_readdir_iterate (ocpdirhandle_pt _dh)
cdrom_track_filename_override_disc,
dirdbFindAndRef (dh->owner->head.dirdb_ref, filename, dirdb_use_file),
1, /* refcount */
1 /* is_nodetect */);
1 /* is_nodetect */,
COMPRESSION_NONE);

dh->owner->head.ref (&dh->owner->head);
file->cdrom = dh->owner->cdrom;
Expand Down Expand Up @@ -864,7 +868,8 @@ static int cdrom_drive_readdir_iterate (ocpdirhandle_pt _dh)
cdrom_track_filename_override_track,
dirdbFindAndRef (dh->owner->head.dirdb_ref, filename, dirdb_use_file),
1, /* refcount */
1 /* is_nodetect */);
1, /* is_nodetect */
COMPRESSION_NONE);

dh->owner->head.ref (&dh->owner->head);
file->cdrom = dh->owner->cdrom;
Expand Down
6 changes: 4 additions & 2 deletions filesel/filesystem-bzip2.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,8 @@ static struct ocpdir_t *bzip2_check_steal (struct ocpfile_t *s, const uint32_t d
s->dirdb_ref,
1, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
s->compression);

s->parent->ref (s->parent);
dirdbRef (s->dirdb_ref, dirdb_use_dir);
Expand All @@ -796,7 +797,8 @@ static struct ocpdir_t *bzip2_check_steal (struct ocpfile_t *s, const uint32_t d
0, /* filename_override */
dirdb_ref,
0, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
COMPRESSION_ADD_STREAM(s->compression));

retval->child.filesize_pending = 1;
retval->child.uncompressed_filesize = 0;
Expand Down
3 changes: 2 additions & 1 deletion filesel/filesystem-dir-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ struct ocpdir_mem_t *ocpdir_mem_alloc (struct ocpdir_t *parent, const char *name
dirdbFindAndRef (parent?parent->dirdb_ref:DIRDB_NOPARENT, name, dirdb_use_dir),
1, /* refcount */
0, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
COMPRESSION_NONE);

if (parent)
{
Expand Down
3 changes: 2 additions & 1 deletion filesel/filesystem-file-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ struct ocpfile_t *dev_file_create
0, /* filename_override */
dirdb_ref, /* we already own this reference */
1, /* refcount */
1 /* is_nodetect */
1, /* is_nodetect */
COMPRESSION_NONE
);

parent->ref (parent);
Expand Down
3 changes: 2 additions & 1 deletion filesel/filesystem-file-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ struct ocpfile_t *mem_file_open (struct ocpdir_t *parent, int dirdb_ref, char *p
0, /* filename_override */
dirdbRef (dirdb_ref, dirdb_use_file),
1, /* refcount */
0 /* is_nodetect */
0, /* is_nodetect */
COMPRESSION_NONE
);

parent->ref (parent);
Expand Down
6 changes: 4 additions & 2 deletions filesel/filesystem-gzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,8 @@ static struct ocpdir_t *gzip_check_steal (struct ocpfile_t *s, const uint32_t di
s->dirdb_ref,
1, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
s->compression);

s->parent->ref (s->parent);
dirdbRef (s->dirdb_ref, dirdb_use_dir);
Expand All @@ -852,7 +853,8 @@ static struct ocpdir_t *gzip_check_steal (struct ocpfile_t *s, const uint32_t di
0, /* filename_override */
dirdb_ref,
1, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
COMPRESSION_ADD_STREAM(s->compression));

retval->child.filesize_pending = 1;
retval->child.uncompressed_filesize = 0;
Expand Down
9 changes: 6 additions & 3 deletions filesel/filesystem-pak.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ static uint32_t pak_instance_add_create_dir (struct pak_instance_t *self,
dirdb_ref,
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
self->archive_file->compression);

self->dirs[self->dir_fill]->owner = self;
self->dirs[self->dir_fill]->dir_parent = dir_parent;
Expand Down Expand Up @@ -451,7 +452,8 @@ static uint32_t pak_instance_add_file (struct pak_instance_t *self,
0, /* filename_override */
dirdb_ref,
0, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
COMPRESSION_ADD_STORE (self->archive_file->compression));

self->files[self->file_fill]->owner = self;
self->files[self->file_fill]->dir_parent = dir_parent;
Expand Down Expand Up @@ -580,7 +582,8 @@ struct ocpdir_t *pak_check (const struct ocpdirdecompressor_t *self, struct ocpf
file->dirdb_ref,
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
file->compression);

file->parent->ref (file->parent);
iter->dirs[0]->owner = iter;
Expand Down
3 changes: 2 additions & 1 deletion filesel/filesystem-playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ struct playlist_instance_t *playlist_instance_allocate (struct ocpdir_t *parent,
dirdbRef (dirdb_ref, dirdb_use_dir),
1, /* refcount */
0, /* is_arhive */
1 /* playlist */);
1, /* playlist */
parent->compression);

if (parent)
{
Expand Down
6 changes: 4 additions & 2 deletions filesel/filesystem-rpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ static uint32_t rpg_instance_add_file (struct rpg_instance_t *self,
0, /* filename_override */
dirdb_ref,
0, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
COMPRESSION_ADD_STORE (self->archive_file->compression));

self->files[self->file_fill]->owner = self;
self->files[self->file_fill]->filesize = filesize;
Expand Down Expand Up @@ -363,7 +364,8 @@ struct ocpdir_t *rpg_check (const struct ocpdirdecompressor_t *self, struct ocpf
file->dirdb_ref,
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
file->compression);

file->parent->ref (file->parent);
iter->dir0.owner = iter;
Expand Down
12 changes: 8 additions & 4 deletions filesel/filesystem-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ static uint32_t tar_instance_add_create_dir (struct tar_instance_t *self,
dirdb_ref,
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
self->archive_file->compression);

self->dirs[self->dir_fill]->owner = self;
self->dirs[self->dir_fill]->dir_parent = dir_parent;
Expand Down Expand Up @@ -402,7 +403,7 @@ static uint32_t tar_instance_add_file (struct tar_instance_t *self,
uint32_t *prev, iter;
uint32_t dirdb_ref;

DEBUG_PRINT ("[TAR] add_file: %s %s\n", Filepath, Filename);
DEBUG_PRINT ("[TAR] add_file: %s %s (offset=%llu size=%llu)\n", Filepath, Filename, (long long unsigned)fileoffset, (long long unsigned)filesize);

if (self->file_fill == self->file_size)
{
Expand Down Expand Up @@ -444,7 +445,8 @@ static uint32_t tar_instance_add_file (struct tar_instance_t *self,
0, /* filename_override */
dirdb_ref,
0, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
COMPRESSION_ADD_STORE (self->archive_file->compression));

self->files[self->file_fill]->owner = self;
self->files[self->file_fill]->dir_parent = dir_parent;
Expand Down Expand Up @@ -570,7 +572,8 @@ struct ocpdir_t *tar_check (const struct ocpdirdecompressor_t *self, struct ocpf
file->dirdb_ref,
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
file->compression);

file->parent->ref (file->parent);
iter->dirs[0]->owner = iter;
Expand Down Expand Up @@ -1054,6 +1057,7 @@ static int tar_filehandle_read (struct ocpfilehandle_t *_self, void *dst, int le
self->error = 1;
return 0;
}
DEBUG_PRINT ("TAR seek_set %llu\n", (long long unsigned)(self->file->fileoffset + self->filepos));
if (filehandle->seek_set (filehandle, self->file->fileoffset + self->filepos) < 0)
{
self->error = 1;
Expand Down
6 changes: 4 additions & 2 deletions filesel/filesystem-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ static struct ocpdir_t *unix_dir_steal (struct ocpdir_t *parent, const uint32_t
dirdb_node,
1, /* refcount */
0, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
COMPRESSION_NONE);

if (parent)
{
Expand Down Expand Up @@ -635,7 +636,8 @@ static struct ocpfile_t *unix_file_steal (struct ocpdir_t *parent, const uint32_
0, /* filename_override */
dirdb_node,
1, /* refcount */
0 /* is_nodetect */
0, /* is_nodetect */
COMPRESSION_NONE
);

parent->ref (parent);
Expand Down
6 changes: 4 additions & 2 deletions filesel/filesystem-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ static struct ocpfile_t *windows_file_steal (struct ocpdir_t *parent, const uint
0, /* filename_override */
dirdb_node,
1, /* refcount */
0 /* is_nodetect */
0, /* is_nodetect */
COMPRESSION_NONE
);

parent->ref (parent);
Expand Down Expand Up @@ -566,7 +567,8 @@ static struct ocpdir_t *windows_dir_steal (struct ocpdir_t *parent, const uint32
dirdb_node,
1, /* refcount */
0, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
COMPRESSION_NONE);

if (parent)
{
Expand Down
6 changes: 4 additions & 2 deletions filesel/filesystem-z.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ static struct ocpdir_t *Z_check_steal (struct ocpfile_t *s, const uint32_t dirdb
s->dirdb_ref,
1, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
s->compression);

s->parent->ref (s->parent);
dirdbRef (s->dirdb_ref, dirdb_use_dir);
Expand All @@ -733,7 +734,8 @@ static struct ocpdir_t *Z_check_steal (struct ocpfile_t *s, const uint32_t dirdb
0, /* filename_override */
dirdb_ref,
0, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
COMPRESSION_ADD_STREAM(s->compression));

retval->child.filesize_pending = 1;
retval->child.uncompressed_filesize = 0;
Expand Down
11 changes: 8 additions & 3 deletions filesel/filesystem-zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ static uint32_t zip_instance_add_create_dir (struct zip_instance_t *self,
dirdb_ref,
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0, /* is_playlist */
self->archive_file->compression);

self->dirs[self->dir_fill]->owner = self;
self->dirs[self->dir_fill]->dir_parent = dir_parent;
Expand Down Expand Up @@ -662,7 +663,10 @@ static uint32_t zip_instance_add_file (struct zip_instance_t *self,
0, /* filename_override */
dirdb_ref,
0, /* refcount */
0 /* is_nodetect */);
0, /* is_nodetect */
(CompressedSize == UncompressedSize) ?
COMPRESSION_ADD_STORE (self->archive_file->compression) :
COMPRESSION_ADD_STREAM (self->archive_file->compression) );

self->files[self->file_fill].owner = self;
self->files[self->file_fill].head.refcount = 0;
Expand Down Expand Up @@ -1083,7 +1087,8 @@ static struct ocpdir_t *zip_check (const struct ocpdirdecompressor_t *self, stru
dirdbRef (file->dirdb_ref, dirdb_use_dir),
0, /* refcount */
1, /* is_archive */
0 /* is_playlist */);
0 /* is_playlist */,
file->compression);

file->parent->ref (file->parent);
iter->dirs[0]->owner = iter;
Expand Down
Loading

0 comments on commit 2da5283

Please sign in to comment.