Fix file permissions
This commit is contained in:
parent
a8ffd073c2
commit
a91b447feb
|
|
@ -3,6 +3,6 @@
|
||||||
rm test.bmp
|
rm test.bmp
|
||||||
gcc -g main.c lib/*.c
|
gcc -g main.c lib/*.c
|
||||||
./a.out
|
./a.out
|
||||||
chmod 777 test.bmp
|
# chmod 777 test.bmp
|
||||||
printf "\n"
|
printf "\n"
|
||||||
xxd test.bmp
|
xxd test.bmp
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,9 @@ bitmap_file write_to_bitmap(const bitmap *bitmap_in, const char *filename) {
|
||||||
bitmap_file new_bitmap_file;
|
bitmap_file new_bitmap_file;
|
||||||
int8_t write_status;
|
int8_t write_status;
|
||||||
uint32_t current_byte;
|
uint32_t current_byte;
|
||||||
uint8_t blank_byte_buffer[1] = { 255 };
|
uint8_t blank_byte_buffer[1] = { 0 };
|
||||||
uint8_t *bitmap_in_byte_ptr = (uint8_t *)bitmap_in + 2; /* Offset by two to account for padding */
|
uint8_t *bitmap_in_byte_ptr = (uint8_t *)bitmap_in + 2; /* Offset by two to account for padding */
|
||||||
int8_t fd = open(filename, O_WRONLY | O_CREAT);
|
int8_t fd = open(filename, O_WRONLY | O_CREAT, 0666);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
/* TODO Need an error return type */
|
/* TODO Need an error return type */
|
||||||
return new_bitmap_file;
|
return new_bitmap_file;
|
||||||
|
|
@ -82,7 +82,8 @@ int write_bitmap_pixel(const bitmap_file *bitmap_file_in, const bitmap_pixel_col
|
||||||
int32_t byte_position_start = byte_position_end_padded - 3;
|
int32_t byte_position_start = byte_position_end_padded - 3;
|
||||||
uint8_t *bitmap_pixel_in_byte_ptr = (uint8_t *)bitmap_pixel_in;
|
uint8_t *bitmap_pixel_in_byte_ptr = (uint8_t *)bitmap_pixel_in;
|
||||||
|
|
||||||
int8_t fd = open(bitmap_file_in->filename, O_WRONLY | O_CREAT);
|
int8_t fd = open(bitmap_file_in->filename, O_WRONLY | O_CREAT, 0666);
|
||||||
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return -1;
|
return -1;
|
||||||
if (byte_position_start % 4)
|
if (byte_position_start % 4)
|
||||||
|
|
|
||||||
15
main.c
15
main.c
|
|
@ -35,19 +35,18 @@ int main() {
|
||||||
//
|
//
|
||||||
// printf("40C == %dF\n", (int) celsius_to_farenheit(40.0));
|
// printf("40C == %dF\n", (int) celsius_to_farenheit(40.0));
|
||||||
|
|
||||||
const bitmap test = init_bitmap(2, 2);
|
const bitmap test = init_bitmap(3, 3);
|
||||||
bitmap_file test_file = write_to_bitmap(&test, "test.bmp");
|
bitmap_file test_file = write_to_bitmap(&test, "test.bmp");
|
||||||
bitmap_pixel_color test_pixel;
|
bitmap_pixel_color test_pixel;
|
||||||
test_pixel.red = 0;
|
test_pixel.red = 255;
|
||||||
test_pixel.green = 0;
|
test_pixel.green = 255;
|
||||||
test_pixel.blue = 0;
|
test_pixel.blue = 255;
|
||||||
bitmap_pixel_color test_pixel2;
|
bitmap_pixel_color test_pixel2;
|
||||||
test_pixel2.red = 0;
|
test_pixel2.red = 100;
|
||||||
test_pixel2.green = 0;
|
test_pixel2.green = 100;
|
||||||
test_pixel2.blue = 255;
|
test_pixel2.blue = 255;
|
||||||
|
|
||||||
write_bitmap_pixel(&test_file, &test_pixel, 1, 2);
|
write_bitmap_pixel(&test_file, &test_pixel, 1, 1);
|
||||||
write_bitmap_pixel(&test_file, &test_pixel2, 2, 2);
|
|
||||||
|
|
||||||
char *reserved_memory = ss_alloc(100);
|
char *reserved_memory = ss_alloc(100);
|
||||||
ss_alloc_free(reserved_memory);
|
ss_alloc_free(reserved_memory);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue