Outputting to DRAM instead of a file while using gzip/gunzip

  • Follow


I am a Linux user. I wish to generate the gzip or gunzip result of a
file into the DRAM space instead of a file, because I want it to run
even in a directory that I have no write permission, and I don't want
to change the file even if I have write permission.

Although it's doable to achieve this goal by writing C code while
making use of gzip/gunzip C source code downloaded somewhere, this
approach needs too much effort. If there's an approach of using gzip/
gunzip of my operation system, but directing the output to a DRAM
space instead of a file, and still allows my further program to access
the virtual file in DRAM, then this is what I prefer. What's more, if
I get the way to do this, then this technique will be applicable not
only to gzip/gunzip, but also to many other shell commands.

Is there such kind of solution?
Many thanks.
0
Reply chen_zhitao (70) 11/6/2009 2:39:43 PM

On Fri, 06 Nov 2009 06:39:43 -0800, Kuhl wrote:

> I am a Linux user. I wish to generate the gzip or gunzip result of a
> file into the DRAM space instead of a file, because I want it to run
> even in a directory that I have no write permission, and I don't want to
> change the file even if I have write permission.

You can extract the file to another location without removing or
changing the original file.

gunzip -c smallfile.gz > /tmp/bigfile 

From the gzip man page:

-c --stdout --to-stdout
   Write output on standard output; keep original files  unchanged.
   If  there  are  several  input  files,  the output consists of a
   sequence of independently compressed members. To  obtain  better
   compression,  concatenate  all  input  files  before compressing them.
0
Reply stonerfish (284) 11/6/2009 3:20:43 PM


jellybean stonerfish wrote:
> On Fri, 06 Nov 2009 06:39:43 -0800, Kuhl wrote:
> 
>> I am a Linux user. I wish to generate the gzip or gunzip result of a
>> file into the DRAM space instead of a file, because I want it to run
>> even in a directory that I have no write permission, and I don't want to
>> change the file even if I have write permission.
> 
> You can extract the file to another location without removing or
> changing the original file.
> 
> gunzip -c smallfile.gz > /tmp/bigfile 
> 
> From the gzip man page:
> 
> -c --stdout --to-stdout
>    Write output on standard output; keep original files  unchanged.
>    If  there  are  several  input  files,  the output consists of a
>    sequence of independently compressed members. To  obtain  better
>    compression,  concatenate  all  input  files  before compressing them.

     You could also use -c without any explicit redirection,
launch the command with a popen() call in your program, and
read the command's standard output from the pipe.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Reply esosman2 (2945) 11/6/2009 4:32:01 PM

2 Replies
37 Views

(page loaded in 0.06 seconds)


Reply: