Skip to main content
added 75 characters in body; edited title
Source Link

I'm having some trouble understanding how to set the unsigned int, I thought I set up theRecover with buffer correctlyfiles, though it won't let me make a headerbut I'm not sure where the image is being sent to, are we rewriting the original card.raw file? I'm confused

#include <stdio.h> #include <stdlib.h> #include <stdint.h>

//number of bytes in jpeg file const int BLOCK_SIZE = 512;

int main(int argc, char *argv[]) { //define memory card char *raw_file = "card.raw";

//ensure proper use
if(argc != 2)
{
    printf("Usage: ./recover [IMAGE]\n");
    return 1;
}

char* infile = argv[1];
char* outfile = argv[1];


//open input file
FILE *input = fopen(argv[1]infile, "r");
if(input==NULL)
{
    printf("Unable to open\n");
    return 1;
}

//open output file
FILE *output = fopen(argv[1]outfile, "w");
if(output==NULL)
{
    fclose(input);
    printf("Could not create\n");
    return 1;
}

typedef uint8_t BYTE;
BYTE header;header[BLOCK_SIZE];
fread(header, sizeof(BLOCK_SIZE), 1, input);
fwrite(header, sizeof(BLOCK_SIZE), 1, output);

//buffer file
int16_t buffer[BLOCK_SIZE];
 while(fread(&buffer, BLOCK_SIZE, 1, input)==BLOCK_SIZE)
{
    char *filecount = argv[1];
    FILE *img= fopen(argv[1], "w");
     //start of jpeg file
if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
{

    sprintf(filecount, "%03i.jpg", 2);
    fwrite(&buffer, BLOCK_SIZE, 1, img);
    continue;
    //check new block if start of next jpeg
    if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
    {
        fclose(output);
        fclose(img);
    }
    else
    {
        fwrite(&buffer, BLOCK_SIZE, 1, img);
    }
}

}

}

I'm having some trouble understanding how to set the unsigned int, I thought I set up the buffer correctly, though it won't let me make a header

#include <stdio.h> #include <stdlib.h> #include <stdint.h>

//number of bytes in jpeg file const int BLOCK_SIZE = 512;

int main(int argc, char *argv[]) { //define memory card char *raw_file = "card.raw";

//ensure proper use
if(argc != 2)
{
    printf("Usage: ./recover [IMAGE]\n");
    return 1;
}


//open input file
FILE *input = fopen(argv[1], "r");
if(input==NULL)
{
    printf("Unable to open\n");
    return 1;
}

//open output file
FILE *output = fopen(argv[1], "w");
if(output==NULL)
{
    fclose(input);
    printf("Could not create\n");
    return 1;
}

typedef uint8_t BYTE;
BYTE header;
fread(header, BLOCK_SIZE, 1, input);
fwrite(header, BLOCK_SIZE, 1, output);

//buffer file
int16_t buffer[BLOCK_SIZE];
 while(fread(&buffer, BLOCK_SIZE, 1, input)==BLOCK_SIZE)
{
    char *filecount = argv[1];
    FILE *img= fopen(argv[1], "w");
     //start of jpeg file
if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
{

    sprintf(filecount, "%03i.jpg", 2);
    fwrite(&buffer, BLOCK_SIZE, 1, img);
    continue;

    if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
    {
        fclose(output);
        fclose(img);
    }
    else
    {
        fwrite(&buffer, BLOCK_SIZE, 1, img);
    }
}

}

}

I set up Recover with buffer files, but I'm not sure where the image is being sent to, are we rewriting the original card.raw file? I'm confused

#include <stdio.h> #include <stdlib.h> #include <stdint.h>

//number of bytes in jpeg file const int BLOCK_SIZE = 512;

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

//ensure proper use
if(argc != 2)
{
    printf("Usage: ./recover [IMAGE]\n");
    return 1;
}

char* infile = argv[1];
char* outfile = argv[1];


//open input file
FILE *input = fopen(infile, "r");
if(input==NULL)
{
    printf("Unable to open\n");
    return 1;
}

//open output file
FILE *output = fopen(outfile, "w");
if(output==NULL)
{
    fclose(input);
    printf("Could not create\n");
    return 1;
}

typedef uint8_t BYTE;
BYTE header[BLOCK_SIZE];
fread(header, sizeof(BLOCK_SIZE), 1, input);
fwrite(header, sizeof(BLOCK_SIZE), 1, output);

//buffer file
int16_t buffer[BLOCK_SIZE];
 while(fread(&buffer, BLOCK_SIZE, 1, input)==BLOCK_SIZE)
{
    char *filecount = argv[1];
    FILE *img= fopen(argv[1], "w");
     //start of jpeg file
if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
{

    sprintf(filecount, "%03i.jpg", 2);
    fwrite(&buffer, BLOCK_SIZE, 1, img);
    continue;
    //check new block if start of next jpeg
    if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
    {
        fclose(output);
        fclose(img);
    }
    else
    {
        fwrite(&buffer, BLOCK_SIZE, 1, img);
    }
}

}

}

added 76 characters in body; edited tags; edited title
Source Link

It says that it could not create, I'm wondering wherehaving some trouble understanding how to set the unsigned int, I may have gone wrong?thought I set up the buffer correctly, though it won't let me make a header

#include <stdio.h> #include <stdlib.h> #include <stdint.h>

//number of bytes in jpeg file const int BLOCK_SIZE = 512;

int main(int argc, char *argv[]) { //define memory card char *raw_file = "card.raw";

//ensure proper use
if(argc != 2)
{
    printf("Usage: ./recover [IMAGE]\n");
    return 1;
}


//open input file
FILE *input = fopen(argv[1], "r");
if(input==NULL)
{
    printf("Unable to open\n");
    return 1;
}

//open output file
FILE *output = fopen(argv[2]argv[1], "w");
if(output==NULL)
{
    fclose(input);
    printf("Could not create\n");
    return 1;
}

typedef uint8_t BYTE;
BYTE header;
fread(argv[1]header, BLOCK_SIZE, 1, input);
fwrite(argv[2]header, BLOCK_SIZE, 1, output);

//buffer file
int16_t buffer[BLOCK_SIZE];
 while(fread(&buffer, BLOCK_SIZE, 1, input)==BLOCK_SIZE)
{
    char *filecount = argv[1];
    FILE *img= fopen(argv[1], "w");
     //start of jpeg file
if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
{

    sprintf(filecount, "%03i.jpg", 2);
    fwrite(&buffer, sizeof(int16_t), 1, output);
    fwrite(buffer, BLOCK_SIZE, 1, img);
    continue;

    if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
    {
        fclose(output);
        fclose(img);
    }
    else
    {
        fwrite(&buffer, BLOCK_SIZE, 1, img);
    }
}

}

}

It says that it could not create, I'm wondering where I may have gone wrong?

#include <stdio.h> #include <stdlib.h> #include <stdint.h>

//number of bytes in jpeg file const int BLOCK_SIZE = 512;

int main(int argc, char *argv[]) { //define memory card char *raw_file = "card.raw";

//ensure proper use
if(argc != 2)
{
    printf("Usage: ./recover [IMAGE]\n");
    return 1;
}


//open input file
FILE *input = fopen(argv[1], "r");
if(input==NULL)
{
    printf("Unable to open\n");
    return 1;
}

//open output file
FILE *output = fopen(argv[2], "w");
if(output==NULL)
{
    fclose(input);
    printf("Could not create\n");
    return 1;
}

fread(argv[1], BLOCK_SIZE, 1, input);
fwrite(argv[2], BLOCK_SIZE, 1, output);

//buffer file
int16_t buffer[BLOCK_SIZE];
 while(fread(&buffer, BLOCK_SIZE, 1, input)==BLOCK_SIZE)
{
    char *filecount = argv[1];
    FILE *img= fopen(argv[1], "w");
     //start of jpeg file
if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
{

    sprintf(filecount, "%03i.jpg", 2);
    fwrite(&buffer, sizeof(int16_t), 1, output);
    fwrite(buffer, BLOCK_SIZE, 1, img);
    continue;

    if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
    {
        fclose(output);
        fclose(img);
    }
}

}

}

I'm having some trouble understanding how to set the unsigned int, I thought I set up the buffer correctly, though it won't let me make a header

#include <stdio.h> #include <stdlib.h> #include <stdint.h>

//number of bytes in jpeg file const int BLOCK_SIZE = 512;

int main(int argc, char *argv[]) { //define memory card char *raw_file = "card.raw";

//ensure proper use
if(argc != 2)
{
    printf("Usage: ./recover [IMAGE]\n");
    return 1;
}


//open input file
FILE *input = fopen(argv[1], "r");
if(input==NULL)
{
    printf("Unable to open\n");
    return 1;
}

//open output file
FILE *output = fopen(argv[1], "w");
if(output==NULL)
{
    fclose(input);
    printf("Could not create\n");
    return 1;
}

typedef uint8_t BYTE;
BYTE header;
fread(header, BLOCK_SIZE, 1, input);
fwrite(header, BLOCK_SIZE, 1, output);

//buffer file
int16_t buffer[BLOCK_SIZE];
 while(fread(&buffer, BLOCK_SIZE, 1, input)==BLOCK_SIZE)
{
    char *filecount = argv[1];
    FILE *img= fopen(argv[1], "w");
     //start of jpeg file
if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
{

    sprintf(filecount, "%03i.jpg", 2);
    fwrite(&buffer, BLOCK_SIZE, 1, img);
    continue;

    if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
    {
        fclose(output);
        fclose(img);
    }
    else
    {
        fwrite(&buffer, BLOCK_SIZE, 1, img);
    }
}

}

}

Source Link

It says that it could not create, I'm wondering where I may have gone wrong?

#include <stdio.h> #include <stdlib.h> #include <stdint.h>

//number of bytes in jpeg file const int BLOCK_SIZE = 512;

int main(int argc, char *argv[]) { //define memory card char *raw_file = "card.raw";

//ensure proper use
if(argc != 2)
{
    printf("Usage: ./recover [IMAGE]\n");
    return 1;
}


//open input file
FILE *input = fopen(argv[1], "r");
if(input==NULL)
{
    printf("Unable to open\n");
    return 1;
}

//open output file
FILE *output = fopen(argv[2], "w");
if(output==NULL)
{
    fclose(input);
    printf("Could not create\n");
    return 1;
}

fread(argv[1], BLOCK_SIZE, 1, input);
fwrite(argv[2], BLOCK_SIZE, 1, output);

//buffer file
int16_t buffer[BLOCK_SIZE];
 while(fread(&buffer, BLOCK_SIZE, 1, input)==BLOCK_SIZE)
{
    char *filecount = argv[1];
    FILE *img= fopen(argv[1], "w");
     //start of jpeg file
if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
{

    sprintf(filecount, "%03i.jpg", 2);
    fwrite(&buffer, sizeof(int16_t), 1, output);
    fwrite(buffer, BLOCK_SIZE, 1, img);
    continue;

    if(buffer[0] == 0xff && buffer[1]== 0xd8 && buffer[2]== 0xff && (buffer[3] & 0xf0) ==0xe0)
    {
        fclose(output);
        fclose(img);
    }
}

}

}