d69ba5 | 2001-09-03 | Martin Nilsson | |
|
a0cd4d | 2000-09-13 | Per Hedbor | | inherit "module";
|
d69ba5 | 2001-09-03 | Martin Nilsson | | constant cvs_version= "$Id: tarfs.pike,v 1.9 2001/09/03 18:10:23 nilsson Exp $";
|
a0cd4d | 2000-09-13 | Per Hedbor | |
constant thread_safe=0;
|
9fa11d | 2001-08-24 | Martin Nilsson | |
|
f0d694 | 2001-01-29 | Per Hedbor | | #define _(X,Y) _DEF_LOCALE("mod_tarfs",X,Y)
|
a0cd4d | 2000-09-13 | Per Hedbor | | #include <module.h>
constant module_type = MODULE_LOCATION;
|
9fa11d | 2001-08-24 | Martin Nilsson | | LocaleString module_name = _(1,"File systems: Tar File");
|
f0d694 | 2001-01-29 | Per Hedbor | | LocaleString module_doc =
|
9fa11d | 2001-08-24 | Martin Nilsson | | _(2,"This is a file system module that makes it possible to mount a "
|
a0cd4d | 2000-09-13 | Per Hedbor | | "directory structure from a tar-file directly on the site. gzip compressed "
"tar-files are not supported");
constant module_unique = 0;
void create()
{
|
f0d694 | 2001-01-29 | Per Hedbor | | defvar( "mountpoint", "/",
|
9fa11d | 2001-08-24 | Martin Nilsson | | _(3,"Mount point"), TYPE_LOCATION|VAR_INITIAL,
_(4,"Where the module will be mounted in the site's virtual file "
|
f0d694 | 2001-01-29 | Per Hedbor | | "system.") );
|
a0cd4d | 2000-09-13 | Per Hedbor | |
|
17013c | 2001-05-16 | Per Hedbor | | defvar("tarfile", "docs.tar",
|
9fa11d | 2001-08-24 | Martin Nilsson | | _(5,"Tar file and root path"), TYPE_FILE|VAR_INITIAL,
_(6,"The tarfile, and an optional root path (syntax: /tar/file.tar:/"
|
f0d694 | 2001-01-29 | Per Hedbor | | "root/dir/)") );
|
a0cd4d | 2000-09-13 | Per Hedbor | | }
string mp, error_msg;
|
973993 | 2000-09-14 | Per Hedbor | |
|
9ceb8b | 2000-09-25 | Per Hedbor | | Filesystem.Tar tar;
|
a0cd4d | 2000-09-13 | Per Hedbor | |
|
17013c | 2001-05-16 | Per Hedbor | | string query_name()
{
return query("mountpoint")+" from "+query("tarfile");
}
|
a0cd4d | 2000-09-13 | Per Hedbor | | void start()
{
string path = "", tf = query( "tarfile" );
mp = query("mountpoint");
sscanf( tf, "%s:%s", tf, path );
tar = 0;
if( catch(tar = Filesystem.Tar( tf )) )
{
report_error( "Failed to open tar-file "+tf+"!" );
tar = 0;
}
else if( strlen( path ) )
tar->cd( path );
}
string query_location()
{
return mp;
}
|
f0d694 | 2001-01-29 | Per Hedbor | | Stat stat_file( string f, RequestID id )
|
a0cd4d | 2000-09-13 | Per Hedbor | | {
if(!tar) return 0;
object s = tar->stat( f );
if( s )
return ({ s->mode, s->size, s->atime, s->mtime, s->ctime, s->uid, s->gid });
}
string real_file( string f, RequestID id )
{
return 0;
}
array find_dir( string f, RequestID id )
{
if(!tar) return 0;
return tar->get_dir( f );
}
mixed find_file( string f, RequestID id )
{
if(!tar) return 0;
object s = tar->stat( f );
if( !s ) return 0;
if( s->isdir() ) return -1;
|
d99bbe | 2001-08-23 | Henrik Grubbström (Grubba) | | return StringFile( tar->open( f, "r" )->read(),
stat_file( f, id ));
|
a0cd4d | 2000-09-13 | Per Hedbor | | }
|