LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-14-2006, 04:37 AM   #1
Markild
LQ Newbie
 
Registered: Dec 2002
Distribution: Ubuntu
Posts: 16

Rep: Reputation: 0
Directory is file


I've downloaded something with bittorrent, and usually that goes great.

I was supposed to end up with a directory with lots of .rar files, but this time I ended up with one huge file. I've looked at the content of this file, and it looks like it really does contain everything.

Anyone got some idea how to make this huge file into a directory? Is it doable?
 
Old 01-14-2006, 04:43 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
use the command "file" on that "directory" to see what it really is. Odds are its some kind of container format, as iv never heard of directories being downloadable.
 
Old 01-14-2006, 11:02 AM   #3
Markild
LQ Newbie
 
Registered: Dec 2002
Distribution: Ubuntu
Posts: 16

Original Poster
Rep: Reputation: 0
It looks like I was able to make a program in C that divided each the archives into separate files. I'll make sure it works, and I can post it here

It's not bulletproof, and it's not great, but it is a way to rescue out some data.
 
Old 01-14-2006, 11:27 AM   #4
Markild
LQ Newbie
 
Registered: Dec 2002
Distribution: Ubuntu
Posts: 16

Original Poster
Rep: Reputation: 0
Feel free to make it "good"

Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include <sys/types.h>

int main(int argc, char *argv[]) {

	FILE *f_in, *f_out;
	int buff[4];
	char outfile[255];

	int i = 1;
	int check = 0;

	sprintf(outfile, "%s.part%d.rar", argv[2], i);

	f_in = fopen(argv[1], "r");
	if (!f_in) { printf("Error: %s\n", strerror(errno)); exit(0); }

	f_out = fopen(outfile, "w");
	if (!f_out) { printf("Error: %s\n", strerror(errno)); exit(0); }

	while (!feof(f_in)) {
		if (check) {
			buff[3] = buff[2];
			buff[2] = buff[1];
			buff[1] = buff[0];
			check--;
		}
		
		buff[0] = fgetc(f_in);
		
		if (!check) {
			if (buff[0] == 'R') check = 4;
			else fputc(buff[0], f_out);
		} else if (check == 1) {
			if ((buff[3] == 82) && (buff[2] == 97) && (buff[1] == 114) && (buff[0] == 33)) {
				i++;

				fclose(f_out);
				sprintf(outfile, "%s.part%d.rar", argv[2], i);

				f_out = fopen(outfile, "w");
				if (!f_out) { printf("Error: %s\n", strerror(errno)); exit(0); }
				printf("New file, part %d\n", i);
			}
			fputc(buff[3], f_out);
			fputc(buff[2], f_out);
			fputc(buff[1], f_out);
			fputc(buff[0], f_out);
		}
	}
	fclose(f_in);
	fclose(f_out);

}
 
Old 01-14-2006, 07:47 PM   #5
Markild
LQ Newbie
 
Registered: Dec 2002
Distribution: Ubuntu
Posts: 16

Original Poster
Rep: Reputation: 0
...and if you for some bizzare reason would like to use the code, or something like it, be sure to compile it with: "gcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64" for >2GB file support...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
libtermcap.so.2: cannot open shared object file: No such file or directory tcma Linux - Software 11 02-24-2012 03:00 AM
awk: fatal:cannot open file for reading (no such file or Directory) in Linux sangati vishwanath Linux - Software 4 07-06-2005 12:59 AM
"cannot create directory: ...no such file or directory" fatblueduck Linux - General 7 06-04-2005 10:08 AM
libawt.so: libXp.so.6: cannot open shared object file: No such file or directory man26 *BSD 0 09-10-2004 08:34 AM
The file or directory file:/misc/cdrom does not exist rangerssg Linux - Newbie 5 08-29-2004 05:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration