Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
ab8790b5
Commit
ab8790b5
authored
26 years ago
by
Marcus Comstedt
Browse files
Options
Downloads
Patches
Plain Diff
Implemented file reading.
Rev: lib/modules/Filesystem.pmod/Tar.pmod:1.2
parent
844ebacd
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Filesystem.pmod/Tar.pmod
+47
-2
47 additions, 2 deletions
lib/modules/Filesystem.pmod/Tar.pmod
with
47 additions
and
2 deletions
lib/modules/Filesystem.pmod/Tar.pmod
+
47
−
2
View file @
ab8790b5
...
@@ -5,6 +5,40 @@ class _Tar // filesystem
...
@@ -5,6 +5,40 @@ class _Tar // filesystem
object fd;
object fd;
string filename;
string filename;
class ReadFile
{
inherit Stdio.File;
static private int start, pos, len;
int seek(int p)
{
if(p<0)
if((p += len)<0)
p = 0;
if(p>=len)
p=len-1;
return ::seek((pos = p)+start);
}
string read(int|void n)
{
if(!query_num_arg() || n>len-pos)
n = len-pos;
pos += n;
return ::read(n);
}
void create(int p, int l)
{
assign(fd->dup());
start = p;
len = l;
seek(0);
}
}
class Record
class Record
{
{
inherit Filesystem.Stat;
inherit Filesystem.Stat;
...
@@ -78,6 +112,14 @@ class _Tar // filesystem
...
@@ -78,6 +112,14 @@ class _Tar // filesystem
'7':0 // contigous
'7':0 // contigous
])[linkflag] || "reg" );
])[linkflag] || "reg" );
}
}
object open(string mode)
{
if(mode!="r")
throw(({"Can only read right now.\n", backtrace()}));
return ReadFile(pos, size);
}
};
};
array entries=({});
array entries=({});
...
@@ -104,10 +146,11 @@ class _Tar // filesystem
...
@@ -104,10 +146,11 @@ class _Tar // filesystem
filename_to_entry[what]=r;
filename_to_entry[what]=r;
}
}
void create(Stdio.File fd,string filename,object parent)
void create(Stdio.File
_
fd,string filename,object parent)
{
{
// read all entries
// read all entries
fd = _fd;
int pos=0; // fd is at position 0 here
int pos=0; // fd is at position 0 here
for (;;)
for (;;)
{
{
...
@@ -203,7 +246,9 @@ class _TarFS
...
@@ -203,7 +246,9 @@ class _TarFS
Stdio.File open(string filename,string mode)
Stdio.File open(string filename,string mode)
{
{
filename=combine_path(wd,filename);
return tar->filename_to_entry[root+filename] &&
tar->filename_to_entry[root+filename]->open(mode);
}
}
int access(string filename,string mode)
int access(string filename,string mode)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment