R
rlp1938
In Windows I can copy VCD from the CD files but in Linux the copy
fails so I wrote a C program to try to copy from the VCD myself.
Running the program gives this result.
file read error
Count 0
Input/output error
Count 0
File desc: 3
Count 0
last failure: Input/output error
What is the difference between Windows and Linux (Ubuntu 10.4) that I
cannot read the file in Linux?
Here is the program below:
/* tryread.c - attempt to read from a cd that gives errors under
Linux but copies using Windows
*/
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char ** argv) {
char *fname = "/media/สร้าง/MPEGAV/AVSEQ01.DAT"; // the file under
test
FILE *fpi, *fpo;
size_t bytes;
char buf[2048];
size_t count = 0;
int ch;
int fdi; // file descriptor for open(..
// first attempt - use fread
fpi = fopen(fname, "r");
if (!(fpi)) {
perror( fname );
exit(1);
} // if()
fpo = fopen("test.dat", "w");
while ((bytes = fread(buf, 1, 2048, fpi)) != 0){
(void) fwrite(buf, 1, bytes, fpo);
count += bytes;
} // while()
if (feof(fpi)) {
puts("end of file found");
} // if()
if (ferror(fpi)) {
puts("file read error");
} // if()
fprintf(stderr, "Count %d\n", count);
// ok the above failed so try char by char
fclose(fpi);
fpi = fopen(fname, "r");
count = 0;
while( (ch = fgetc(fpi)) != EOF ) {
count++;
fputc(ch, fpo);
} // while()
perror("");
fprintf(stderr, "Count %d\n", count);
// ok another failure logged so let's try the lower level stuff
fclose(fpi);
fdi = open(fname, O_RDONLY);
fprintf(stderr, "File desc: %d\n", fdi);
count = 0;
while ( (bytes = read(fdi, buf, 2048)) != -1) {
count += bytes;
fprintf(stderr, "Read: %d\n", count);
} // while()
fprintf(stderr, "Count %d\n", count);
perror("last failure");
fclose(fpo);
return 0;
} // main()
fails so I wrote a C program to try to copy from the VCD myself.
Running the program gives this result.
file read error
Count 0
Input/output error
Count 0
File desc: 3
Count 0
last failure: Input/output error
What is the difference between Windows and Linux (Ubuntu 10.4) that I
cannot read the file in Linux?
Here is the program below:
/* tryread.c - attempt to read from a cd that gives errors under
Linux but copies using Windows
*/
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char ** argv) {
char *fname = "/media/สร้าง/MPEGAV/AVSEQ01.DAT"; // the file under
test
FILE *fpi, *fpo;
size_t bytes;
char buf[2048];
size_t count = 0;
int ch;
int fdi; // file descriptor for open(..
// first attempt - use fread
fpi = fopen(fname, "r");
if (!(fpi)) {
perror( fname );
exit(1);
} // if()
fpo = fopen("test.dat", "w");
while ((bytes = fread(buf, 1, 2048, fpi)) != 0){
(void) fwrite(buf, 1, bytes, fpo);
count += bytes;
} // while()
if (feof(fpi)) {
puts("end of file found");
} // if()
if (ferror(fpi)) {
puts("file read error");
} // if()
fprintf(stderr, "Count %d\n", count);
// ok the above failed so try char by char
fclose(fpi);
fpi = fopen(fname, "r");
count = 0;
while( (ch = fgetc(fpi)) != EOF ) {
count++;
fputc(ch, fpo);
} // while()
perror("");
fprintf(stderr, "Count %d\n", count);
// ok another failure logged so let's try the lower level stuff
fclose(fpi);
fdi = open(fname, O_RDONLY);
fprintf(stderr, "File desc: %d\n", fdi);
count = 0;
while ( (bytes = read(fdi, buf, 2048)) != -1) {
count += bytes;
fprintf(stderr, "Read: %d\n", count);
} // while()
fprintf(stderr, "Count %d\n", count);
perror("last failure");
fclose(fpo);
return 0;
} // main()