Commit ad7350b1 authored by Tobias Ellinghaus's avatar Tobias Ellinghaus

Use g_open() and g_unlink()

These are needed to properly support non-ASCII paths on Windows. We
poison unlink(), however, with open() that's not possible, it's used in
some system header.
parent 50d91bdf
......@@ -294,7 +294,7 @@ static void _camera_process_job(const dt_camctl_t *c, const dt_camera_t *camera,
char *output = g_build_filename(output_path, fname, (char *)NULL);
int handle = open(output, O_CREAT | O_WRONLY, 0666);
int handle = g_open(output, O_CREAT | O_WRONLY, 0666);
if(handle != -1)
{
gp_file_new_from_fd(&destination, handle);
......@@ -933,7 +933,7 @@ void dt_camctl_import(const dt_camctl_t *c, const dt_camera_t *cam, GList *image
char *output = g_build_filename(output_path, fname, (char *)NULL);
int handle = open(output, O_CREAT | O_WRONLY, 0666);
int handle = g_open(output, O_CREAT | O_WRONLY, 0666);
if (handle > 0) {
if (write(handle, data, size) > 0) {
_dispatch_camera_image_downloaded(c, cam, output);
......@@ -1443,7 +1443,7 @@ void _camera_poll_events(const dt_camctl_t *c, const dt_camera_t *cam)
char *output = g_build_filename(output_path, fname, (char *)NULL);
int handle = open(output, O_CREAT | O_WRONLY, 0666);
int handle = g_open(output, O_CREAT | O_WRONLY, 0666);
if(handle != -1)
{
gp_file_new_from_fd(&destination, handle);
......
......@@ -99,7 +99,7 @@ dt_printer_info_t *dt_get_printer_info(const char *printer_name)
result->resolution /= 2.0;
ppdClose(ppd);
unlink(PPDFile);
g_unlink(PPDFile);
}
}
......@@ -306,7 +306,7 @@ GList *dt_get_papers(const char *printer_name)
}
ppdClose(ppd);
unlink(PPDFile);
g_unlink(PPDFile);
}
result = g_list_sort_with_data (result, (GCompareDataFunc)sort_papers, NULL);
......
......@@ -1623,9 +1623,9 @@ int dt_opencl_load_program(const int dev, const int prog, const char *filename,
{
char link_dest[PATH_MAX] = { 0 };
snprintf(link_dest, sizeof(link_dest), "%s/%s", cachedir, linkedfile);
unlink(link_dest);
g_unlink(link_dest);
}
unlink(binname);
g_unlink(binname);
dt_print(DT_DEBUG_OPENCL,
"[opencl_load_program] could not load cached binary program, trying to compile source\n");
......
......@@ -20,6 +20,8 @@
#pragma GCC poison strncat // use g_strncat
#pragma GCC poison pthread_create // use dt_pthread_create, musl issues
#pragma GCC poison fopen // use g_fopen
// #pragma GCC poison open // use g_open -- this one doesn't work
#pragma GCC poison unlink // use g_unlink
#endif
......
......@@ -803,7 +803,7 @@ void dt_styles_save_to_file(const char *style_name, const char *filedir, gboolea
{
if(overwrite)
{
if(unlink(stylename))
if(g_unlink(stylename))
{
dt_control_log(_("failed to overwrite style file for %s"), style_name);
return;
......
......@@ -162,7 +162,7 @@ void dt_set_unhandled_exception_handler_win()
if(fout != STDOUT_FILENO)
{
close(fout);
unlink(name_used);
g_unlink(name_used);
};
// Set up logfile name
......
......@@ -811,7 +811,7 @@ void free_params(dt_imageio_module_format_t *self, dt_imageio_module_data_t *par
if(d->actual_filename)
{
unlink(d->actual_filename); // no need to leave broken files on disk
g_unlink(d->actual_filename); // no need to leave broken files on disk
g_free(d->actual_filename);
}
......
......@@ -1329,7 +1329,7 @@ int store(dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *sd
}
cleanup:
unlink(fname);
g_unlink(fname);
g_free(caption);
if(result)
......
......@@ -707,7 +707,7 @@ int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, co
cleanup:
// And remove from filesystem..
unlink(fname);
g_unlink(fname);
g_free(caption);
if(desc) g_list_free_full(desc, &g_free);
......
......@@ -1298,7 +1298,7 @@ int store(dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *sd
}
cleanup:
unlink(fname);
g_unlink(fname);
g_free(title);
g_list_free_full(meta_title, &g_free);
......
......@@ -352,7 +352,7 @@ _print_button_clicked (GtkWidget *widget, gpointer user_data)
dt_print_file (imgid, filename, &ps->prt);
unlink(filename);
g_unlink(filename);
// add tag for this image
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment