3
* Copyright (c) 2005-2007 Benedikt Meurer <benny@xfce.org>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
25
#ifdef HAVE_SYS_TYPES_H
26
#include <sys/types.h>
28
#ifdef HAVE_SYS_STAT_H
42
#include <thunar-vfs/thunar-vfs-enum-types.h>
43
#include <thunar-vfs/thunar-vfs-info.h>
44
#include <thunar-vfs/thunar-vfs-io-jobs.h>
45
#include <thunar-vfs/thunar-vfs-io-local.h>
46
#include <thunar-vfs/thunar-vfs-io-ops.h>
47
#include <thunar-vfs/thunar-vfs-io-scandir.h>
48
#include <thunar-vfs/thunar-vfs-io-trash.h>
49
#include <thunar-vfs/thunar-vfs-monitor-private.h>
50
#include <thunar-vfs/thunar-vfs-private.h>
51
#include <thunar-vfs/thunar-vfs-alias.h>
53
/* use g_chmod(), g_open() and g_stat() on win32 */
54
#if defined(G_OS_WIN32)
55
#include <glib/gstdio.h>
57
#define g_chmod(path, mode) (chmod ((path), (mode)))
58
#define g_open(path, flags, mode) (open ((path), (flags), (mode)))
59
#define g_stat(path, statb) (stat ((path), (statb)))
64
static GList *tvij_collect_nofollow (ThunarVfsJob *job,
65
GList *base_path_list,
66
GError **error) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
71
tvij_collect_nofollow (ThunarVfsJob *job,
72
GList *base_path_list,
76
GList *child_path_list;
77
GList *path_list = NULL;
80
/* tell the user that we're preparing to unlink the files */
81
_thunar_vfs_job_info_message (job, _("Preparing..."));
83
/* recursively collect the paths */
84
for (lp = base_path_list; err == NULL && lp != NULL && !thunar_vfs_job_cancelled (job); lp = lp->next)
86
/* try to scan the path as directory */
87
child_path_list = _thunar_vfs_io_scandir (lp->data, &job->cancelled, THUNAR_VFS_IO_SCANDIR_RECURSIVE, &err);
88
if (G_UNLIKELY (err != NULL))
90
/* we can safely ignore ENOENT/ENOTDIR errors here */
91
if (err->domain == G_FILE_ERROR && (err->code == G_FILE_ERROR_NOENT || err->code == G_FILE_ERROR_NOTDIR))
98
/* prepend the new paths to the existing list */
99
path_list = thunar_vfs_path_list_prepend (path_list, lp->data);
100
path_list = g_list_concat (child_path_list, path_list);
103
/* check if we failed */
104
if (G_UNLIKELY (err != NULL))
106
/* release the collected paths */
107
thunar_vfs_path_list_free (path_list);
109
/* propagate the error */
110
g_propagate_error (error, err);
120
* _thunar_vfs_io_jobs_chmod:
121
* @job : a #ThunarVfsJob.
122
* @param_values : exactly six #GValue with the #GList of #ThunarVfsPath<!---->s
123
* for the files whose mode to changed, the directory mode mask,
124
* the directory mode, the file mask, the file mode and a boolean
125
* flag telling whether to recursively process directories.
126
* @n_param_values : the number of #GValue<!---->s in @param_values, must be exactly
128
* @error : return location for errors or %NULL.
130
* See thunar_vfs_change_mode() for details.
132
* The #ThunarVfsPath<!---->s in the first item of @param_values may only include local
133
* paths with scheme %THUNAR_VFS_PATH_SCHEME_FILE.
135
* Return value: %TRUE if the changing of permissions succeed, %FALSE otherwise.
138
_thunar_vfs_io_jobs_chmod (ThunarVfsJob *job,
139
const GValue *param_values,
140
guint n_param_values,
143
ThunarVfsFileMode file_mask = g_value_get_flags (¶m_values[3]);
144
ThunarVfsFileMode file_mode = g_value_get_flags (¶m_values[4]);
145
ThunarVfsFileMode dir_mask = g_value_get_flags (¶m_values[1]);
146
ThunarVfsFileMode dir_mode = g_value_get_flags (¶m_values[2]);
147
ThunarVfsFileMode mask;
148
ThunarVfsFileMode mode;
150
gboolean recursive = g_value_get_boolean (¶m_values[5]);
153
GList *path_list = g_value_get_boxed (¶m_values[0]);
155
gchar *absolute_path;
159
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[1], THUNAR_VFS_TYPE_VFS_FILE_MODE), FALSE);
160
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[2], THUNAR_VFS_TYPE_VFS_FILE_MODE), FALSE);
161
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[3], THUNAR_VFS_TYPE_VFS_FILE_MODE), FALSE);
162
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[4], THUNAR_VFS_TYPE_VFS_FILE_MODE), FALSE);
163
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[0], THUNAR_VFS_TYPE_PATH_LIST), FALSE);
164
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[5], G_TYPE_BOOLEAN), FALSE);
165
_thunar_vfs_return_val_if_fail (error == NULL || *error == NULL, FALSE);
166
_thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_JOB (job), FALSE);
167
_thunar_vfs_return_val_if_fail (n_param_values == 6, FALSE);
169
#ifdef G_ENABLE_DEBUG
170
/* verify that we have only local paths */
171
for (lp = path_list; lp != NULL; lp = lp->next)
172
_thunar_vfs_assert (_thunar_vfs_path_is_local (lp->data));
175
/* collect the paths for the chmod operation */
176
path_list = recursive ? tvij_collect_nofollow (job, path_list, &err) : thunar_vfs_path_list_copy (path_list);
177
if (G_UNLIKELY (err != NULL))
179
/* propagate the error */
180
g_propagate_error (error, err);
184
/* we know the total list of paths to process now */
185
_thunar_vfs_job_total_paths (job, path_list);
187
/* change the permissions of all paths */
188
for (lp = path_list; lp != NULL && !thunar_vfs_job_cancelled (job); lp = lp->next)
191
/* reset the saved errno */
194
/* update the progress information */
195
_thunar_vfs_job_process_path (job, lp);
197
/* try to stat the file */
198
absolute_path = thunar_vfs_path_dup_string (lp->data);
199
if (g_stat (absolute_path, &statb) == 0)
201
/* different actions depending on the type of the file */
202
mask = S_ISDIR (statb.st_mode) ? dir_mask : file_mask;
203
mode = S_ISDIR (statb.st_mode) ? dir_mode : file_mode;
205
/* determine the new mode */
206
mode = ((statb.st_mode & ~mask) | mode) & 07777;
208
/* try to apply the new mode */
209
if (g_chmod (absolute_path, mode) < 0)
212
/* feed a change notification event */
213
thunar_vfs_monitor_feed (_thunar_vfs_monitor, THUNAR_VFS_MONITOR_EVENT_CHANGED, lp->data);
221
g_free (absolute_path);
223
/* check if we failed (ignoring ENOENT) */
224
if (G_UNLIKELY (sverrno != 0 && sverrno != ENOENT))
226
/* generate an error */
227
display_name = _thunar_vfs_path_dup_display_name (lp->data);
228
_thunar_vfs_set_g_error_from_errno2 (&err, sverrno, _("Failed to change permissions of \"%s\""), display_name);
229
g_free (display_name);
231
/* ask the user whether to skip this one */
232
retry = (_thunar_vfs_job_ask_skip (job, "%s", err->message) == THUNAR_VFS_JOB_RESPONSE_RETRY);
234
/* reset the error */
235
g_clear_error (&err);
237
/* check whether to retry */
238
if (G_UNLIKELY (retry))
243
/* release the path list */
244
thunar_vfs_path_list_free (path_list);
252
* _thunar_vfs_io_jobs_chown:
253
* @job : a #ThunarVfsJob.
254
* @param_values : exactly four #GValue with the #GList of #ThunarVfsPath<!---->s
255
* for the files whose ownership to changed, the new user id or %-1,
256
* the new group id or %-1, and a boolean flag telling whether to
257
* recursively process directories.
258
* @n_param_values : the number of #GValue<!---->s in @param_values, must be exactly
260
* @error : return location for errors or %NULL.
262
* See thunar_vfs_change_group() and thunar_vfs_change_owner() for details.
264
* The #ThunarVfsPath<!---->s in the first item of @param_values may only include local
265
* paths with scheme %THUNAR_VFS_PATH_SCHEME_FILE.
267
* Return value: %TRUE if the changing of ownership succeed, %FALSE otherwise.
270
_thunar_vfs_io_jobs_chown (ThunarVfsJob *job,
271
const GValue *param_values,
272
guint n_param_values,
276
gboolean recursive = g_value_get_boolean (¶m_values[3]);
279
GList *path_list = g_value_get_boxed (¶m_values[0]);
281
gchar *absolute_path;
284
gint uid = g_value_get_int (¶m_values[1]);
285
gint gid = g_value_get_int (¶m_values[2]);
289
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[0], THUNAR_VFS_TYPE_PATH_LIST), FALSE);
290
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[3], G_TYPE_BOOLEAN), FALSE);
291
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[1], G_TYPE_INT), FALSE);
292
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[2], G_TYPE_INT), FALSE);
293
_thunar_vfs_return_val_if_fail (error == NULL || *error == NULL, FALSE);
294
_thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_JOB (job), FALSE);
295
_thunar_vfs_return_val_if_fail (uid >= 0 || gid >= 0, FALSE);
296
_thunar_vfs_return_val_if_fail (n_param_values == 4, FALSE);
298
#ifdef G_ENABLE_DEBUG
299
/* verify that we have only local paths */
300
for (lp = path_list; lp != NULL; lp = lp->next)
301
_thunar_vfs_assert (_thunar_vfs_path_is_local (lp->data));
304
/* collect the paths for the chown operation */
305
path_list = recursive ? tvij_collect_nofollow (job, path_list, &err) : thunar_vfs_path_list_copy (path_list);
306
if (G_UNLIKELY (err != NULL))
308
/* propagate the error */
309
g_propagate_error (error, err);
313
/* we know the total list of paths to process now */
314
_thunar_vfs_job_total_paths (job, path_list);
316
/* change the ownership of all paths */
317
for (lp = path_list; lp != NULL && !thunar_vfs_job_cancelled (job); lp = lp->next)
320
/* reset the saved errno */
323
/* update the progress information */
324
_thunar_vfs_job_process_path (job, lp);
326
/* try to stat the file */
327
absolute_path = thunar_vfs_path_dup_string (lp->data);
328
if (g_stat (absolute_path, &statb) == 0)
330
/* determine the new uid/gid */
331
nuid = (uid < 0) ? (gint) statb.st_uid : uid;
332
ngid = (gid < 0) ? (gint) statb.st_gid : gid;
334
/* try to apply the new ownership */
335
if (chown (absolute_path, nuid, ngid) < 0)
338
/* feed a change notification event */
339
thunar_vfs_monitor_feed (_thunar_vfs_monitor, THUNAR_VFS_MONITOR_EVENT_CHANGED, lp->data);
347
g_free (absolute_path);
349
/* check if we failed (ignoring ENOENT) */
350
if (G_UNLIKELY (sverrno != 0 && sverrno != ENOENT))
352
/* generate an error */
353
display_name = _thunar_vfs_path_dup_display_name (lp->data);
354
_thunar_vfs_set_g_error_from_errno2 (&err, sverrno, G_LIKELY (uid >= 0)
355
? _("Failed to change file owner of \"%s\"")
356
: _("Failed to change file group of \"%s\""),
358
g_free (display_name);
360
/* ask the user whether to skip/retry this one */
361
retry = (_thunar_vfs_job_ask_skip (job, "%s", err->message) == THUNAR_VFS_JOB_RESPONSE_RETRY);
363
/* reset the error */
364
g_clear_error (&err);
366
/* check whether to retry */
367
if (G_UNLIKELY (retry))
372
/* release the path list */
373
thunar_vfs_path_list_free (path_list);
381
* _thunar_vfs_io_jobs_create:
382
* @job : a #ThunarVfsJob.
383
* @param_values : exactly one #GValue with the #GList of #ThunarVfsPath<!---->s
384
* for which to create new files.
385
* @n_param_values : the number of #GValue<!---->s in @param_values, must be exactly
387
* @error : return location for errors or %NULL.
389
* Creates empty files for all #ThunarVfsPath<!---->s specified in @param_values.
391
* The #ThunarVfsPath<!---->s in @param_values may only include local paths with scheme
392
* %THUNAR_VFS_PATH_SCHEME_FILE.
394
* Return value: %TRUE if the creation of the files succeed, %FALSE otherwise.
397
_thunar_vfs_io_jobs_create (ThunarVfsJob *job,
398
const GValue *param_values,
399
guint n_param_values,
402
ThunarVfsJobResponse response;
404
gchar *absolute_path;
407
GList *path_list = g_value_get_boxed (¶m_values[0]);
411
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[0], THUNAR_VFS_TYPE_PATH_LIST), FALSE);
412
_thunar_vfs_return_val_if_fail (error == NULL || *error == NULL, FALSE);
413
_thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_JOB (job), FALSE);
414
_thunar_vfs_return_val_if_fail (n_param_values == 1, FALSE);
416
#ifdef G_ENABLE_DEBUG
417
/* verify that we have only local paths */
418
for (lp = path_list; lp != NULL; lp = lp->next)
419
_thunar_vfs_assert (_thunar_vfs_path_is_local (lp->data));
422
/* we know the total paths to be processed */
423
_thunar_vfs_job_total_paths (job, path_list);
425
/* process all paths */
426
for (lp = path_list; err == NULL && lp != NULL && !thunar_vfs_job_cancelled (job); lp = lp->next)
428
/* update the progress information */
429
_thunar_vfs_job_process_path (job, lp);
431
/* determine the absolute path to the path object */
432
absolute_path = thunar_vfs_path_dup_string (lp->data);
435
/* Try to create the file at the given path.
437
* Note that despite the 0666 mask, we won't really create a world-writable
438
* file unless the user's umask permits it (ie the umask is 0000).
440
fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, 0666);
441
if (G_UNLIKELY (fd < 0))
443
/* check if the file already exists */
444
if (G_UNLIKELY (errno == EEXIST))
446
/* ask the user whether to override this path */
447
display_name = _thunar_vfs_path_dup_display_name (lp->data);
448
response = _thunar_vfs_job_ask_overwrite (job, _("The file \"%s\" already exists"), display_name);
449
g_free (display_name);
451
/* check if we should overwrite */
452
if (G_UNLIKELY (response == THUNAR_VFS_JOB_RESPONSE_YES))
454
/* try to remove the file (fail if not possible) */
455
if (_thunar_vfs_io_ops_remove (lp->data, THUNAR_VFS_IO_OPS_IGNORE_ENOENT, &err))
464
/* ask the user whether to skip/retry this path (cancels the job if not) */
465
display_name = _thunar_vfs_path_dup_display_name (lp->data);
466
message = g_strdup_printf (_("Failed to create empty file \"%s\""), display_name);
467
response = _thunar_vfs_job_ask_skip (job, "%s: %s", message, g_strerror (errno));
468
g_free (display_name);
471
/* check whether to retry the create operation */
472
if (response == THUNAR_VFS_JOB_RESPONSE_RETRY)
478
/* feed a "created" event for the new file */
479
thunar_vfs_monitor_feed (_thunar_vfs_monitor, THUNAR_VFS_MONITOR_EVENT_CREATED, lp->data);
486
g_free (absolute_path);
489
/* check if we failed */
490
if (G_UNLIKELY (err != NULL))
492
/* propagate the error */
493
g_propagate_error (error, err);
497
/* emit the "new-files" signal with the given path list */
498
_thunar_vfs_job_new_files (job, path_list);
506
* _thunar_vfs_io_jobs_link:
507
* @job : a #ThunarVfsJob.
508
* @param_values : exactly two #GValue<!---->s with the #GList of #ThunarVfsPath<!---->s
509
* for the source paths and the target paths.
510
* @n_param_values : the number of #GValue<!---->s in @param_values, must be exactly
512
* @error : return location for errors or %NULL.
514
* Creates symbolic links from all #ThunarVfsPath<!---->s in the first parameter of @param_values
515
* to the corresponding #ThunarVfsPath<!---->s in the second parameter of @param_values.
517
* The #ThunarVfsPath<!---->s in both @param_values may only include local paths with scheme
518
* %THUNAR_VFS_PATH_SCHEME_FILE.
520
* Return value: %TRUE if the link were created successfully, %FALSE otherwise.
523
_thunar_vfs_io_jobs_link (ThunarVfsJob *job,
524
const GValue *param_values,
525
guint n_param_values,
528
ThunarVfsJobResponse overwrite;
529
ThunarVfsPath *target_path;
531
GList *source_path_list = g_value_get_boxed (¶m_values[0]);
532
GList *target_path_list = g_value_get_boxed (¶m_values[1]);
536
_thunar_vfs_return_val_if_fail (g_list_length (source_path_list) == g_list_length (target_path_list), FALSE);
537
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[0], THUNAR_VFS_TYPE_PATH_LIST), FALSE);
538
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[1], THUNAR_VFS_TYPE_PATH_LIST), FALSE);
539
_thunar_vfs_return_val_if_fail (error == NULL || *error == NULL, FALSE);
540
_thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_JOB (job), FALSE);
541
_thunar_vfs_return_val_if_fail (n_param_values == 2, FALSE);
543
/* we know the total list of paths to process */
544
_thunar_vfs_job_total_paths (job, source_path_list);
546
/* process all files */
547
for (sp = source_path_list, tp = target_path_list; err == NULL && sp != NULL; sp = sp->next, tp = tp->next)
549
/* check if the job was cancelled by the user */
550
if (G_UNLIKELY (thunar_vfs_job_cancelled (job)))
553
/* update the progress information */
554
_thunar_vfs_job_process_path (job, sp);
557
/* try to perform the symlink operation */
558
if (_thunar_vfs_io_ops_link_file (sp->data, tp->data, &target_path, &err))
560
/* replace the path on the target path list */
561
thunar_vfs_path_unref (tp->data);
562
tp->data = target_path;
564
else if (G_LIKELY (err->domain == G_FILE_ERROR && err->code == G_FILE_ERROR_EXIST))
566
/* ask the user whether we should remove the target first */
567
overwrite = _thunar_vfs_job_ask_overwrite (job, "%s", err->message);
569
/* release the error */
570
g_clear_error (&err);
572
/* check if we should overwrite the existing file */
573
if (G_LIKELY (overwrite == THUNAR_VFS_JOB_RESPONSE_YES))
575
/* try to remove the target file (fail if not possible) */
576
if (_thunar_vfs_io_ops_remove (tp->data, THUNAR_VFS_IO_OPS_IGNORE_ENOENT, &err))
585
/* check if we failed */
586
if (G_UNLIKELY (err != NULL))
588
/* propagate the error */
589
g_propagate_error (error, err);
593
/* emit the "new-files" signal for the target paths */
594
_thunar_vfs_job_new_files (job, target_path_list);
602
* _thunar_vfs_io_jobs_listdir:
603
* @job : a #ThunarVfsJob.
604
* @param_values : exactly one #GValue with the #ThunarVfsPath of the folder whose
606
* @n_param_values : the number of #GValue<!---->s in @param_values, must be exactly
608
* @error : return location for errors or %NULL.
610
* Lists the contents of the folder at the #ThunarVfsPath in @param_values.
612
* Return value: %TRUE if the folder contents were successfully listed, %FALSE otherwise.
615
_thunar_vfs_io_jobs_listdir (ThunarVfsJob *job,
616
const GValue *param_values,
617
guint n_param_values,
620
ThunarVfsPath *path = g_value_get_boxed (¶m_values[0]);
624
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[0], THUNAR_VFS_TYPE_PATH), FALSE);
625
_thunar_vfs_return_val_if_fail (error == NULL || *error == NULL, FALSE);
626
_thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_JOB (job), FALSE);
627
_thunar_vfs_return_val_if_fail (n_param_values == 1, FALSE);
629
/* determine the type of directory to scan */
630
switch (thunar_vfs_path_get_scheme (path))
632
case THUNAR_VFS_PATH_SCHEME_FILE:
633
info_list = _thunar_vfs_io_local_listdir (path, &err);
636
case THUNAR_VFS_PATH_SCHEME_TRASH:
637
info_list = _thunar_vfs_io_trash_listdir (path, &err);
641
_thunar_vfs_set_g_error_not_supported (error);
645
/* check if we have any files to report */
646
if (G_LIKELY (info_list != NULL))
648
/* emit the "infos-ready" signal with the given list */
649
if (!_thunar_vfs_job_infos_ready (job, info_list))
651
/* if none of the handlers took over ownership, we still
652
* own it and we are thereby responsible to release it.
654
thunar_vfs_info_list_free (info_list);
657
else if (err != NULL)
659
/* propagate the error to the caller */
660
g_propagate_error (error, err);
670
* _thunar_vfs_io_jobs_mkdir:
671
* @job : a #ThunarVfsJob.
672
* @param_values : exactly one #GValue with the #GList of #ThunarVfsPath<!---->s
673
* for which to create new directories.
674
* @n_param_values : the number of #GValue<!---->s in @param_values, must be exactly
676
* @error : return location for errors or %NULL.
678
* Creates new directories for all #ThunarVfsPath<!---->s specified in @param_values.
680
* The #ThunarVfsPath<!---->s in @param_values may only include local paths with scheme
681
* %THUNAR_VFS_PATH_SCHEME_FILE.
683
* Return value: %TRUE if the creation of the folders succeed, %FALSE otherwise.
686
_thunar_vfs_io_jobs_mkdir (ThunarVfsJob *job,
687
const GValue *param_values,
688
guint n_param_values,
691
GList *path_list = g_value_get_boxed (¶m_values[0]);
694
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[0], THUNAR_VFS_TYPE_PATH_LIST), FALSE);
695
_thunar_vfs_return_val_if_fail (error == NULL || *error == NULL, FALSE);
696
_thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_JOB (job), FALSE);
697
_thunar_vfs_return_val_if_fail (n_param_values == 1, FALSE);
699
#ifdef G_ENABLE_DEBUG
700
/* verify that we have only local paths */
701
for (lp = path_list; lp != NULL; lp = lp->next)
702
_thunar_vfs_assert (_thunar_vfs_path_is_local (lp->data));
705
/* we know the total list of paths to process */
706
_thunar_vfs_job_total_paths (job, path_list);
708
/* process all directories */
709
for (lp = path_list; lp != NULL && !thunar_vfs_job_cancelled (job); lp = lp->next)
711
/* update the progress information */
712
_thunar_vfs_job_process_path (job, lp);
714
/* try to create the target directory
716
* Note that the mode specified here is limited by the user's umask, so we will not
717
* actually be creating a world writable directory unless the user's umask permits
720
if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777, THUNAR_VFS_IO_OPS_NONE, error))
724
/* emit the "new-files" signal */
725
_thunar_vfs_job_new_files (job, path_list);
732
* _thunar_vfs_io_jobs_unlink:
733
* @job : a #ThunarVfsJob.
734
* @param_values : exactly one #GValue with the #GList of #ThunarVfsPath<!---->s
735
* for the files and folders which should be unlinked recursively.
736
* @n_param_values : the number of #GValue<!---->s in @param_values, must be exactly
738
* @error : return location for errors or %NULL.
740
* Recursively unlinks all #ThunarVfsPath<!---->s specified in @param_values.
742
* Return value: %TRUE if the unlink operation succeed, %FALSE otherwise.
745
_thunar_vfs_io_jobs_unlink (ThunarVfsJob *job,
746
const GValue *param_values,
747
guint n_param_values,
755
_thunar_vfs_return_val_if_fail (G_VALUE_HOLDS (¶m_values[0], THUNAR_VFS_TYPE_PATH_LIST), FALSE);
756
_thunar_vfs_return_val_if_fail (error == NULL || *error == NULL, FALSE);
757
_thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_JOB (job), FALSE);
758
_thunar_vfs_return_val_if_fail (n_param_values == 1, FALSE);
760
/* collect the paths for the removal */
761
path_list = tvij_collect_nofollow (job, g_value_get_boxed (¶m_values[0]), &err);
762
if (G_UNLIKELY (err != NULL))
764
/* propagate the error */
765
g_propagate_error (error, err);
769
/* we know the total list of paths to process */
770
_thunar_vfs_job_total_paths (job, path_list);
772
/* perform the actual removal of the paths */
773
for (lp = path_list; lp != NULL && !thunar_vfs_job_cancelled (job); lp = lp->next)
775
/* update the progress information */
776
_thunar_vfs_job_process_path (job, lp);
778
/* skip the root folders, which cannot be deleted anyway */
779
if (G_LIKELY (!thunar_vfs_path_is_root (lp->data)))
781
again: /* remove the file for the current path */
782
if (!_thunar_vfs_io_ops_remove (lp->data, THUNAR_VFS_IO_OPS_IGNORE_ENOENT, &err))
784
/* ask the user whether to skip the file */
785
retry = (_thunar_vfs_job_ask_skip (job, "%s", err->message) == THUNAR_VFS_JOB_RESPONSE_RETRY);
787
/* clear the error */
788
g_clear_error (&err);
790
/* check whether to retry */
791
if (G_UNLIKELY (retry))
797
/* release the path list */
798
thunar_vfs_path_list_free (path_list);
805
#define __THUNAR_VFS_IO_JOBS_C__
806
#include <thunar-vfs/thunar-vfs-aliasdef.c>