mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-20 18:29:19 +03:00
Changed input parameters of mc_mkstemp() and mc_tempdir() functions
to handle vfs_path_t type. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
f2dc217060
commit
389ac85992
@ -1220,7 +1220,11 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
vfs_s_insert_entry (path_element->class, dir, ent);
|
vfs_s_insert_entry (path_element->class, dir, ent);
|
||||||
if ((VFSDATA (path_element)->flags & VFS_S_USETMP) != 0)
|
if ((VFSDATA (path_element)->flags & VFS_S_USETMP) != 0)
|
||||||
{
|
{
|
||||||
tmp_handle = vfs_mkstemps (&ino->localname, path_element->class->name, name);
|
vfs_path_t *tmp_vpath;
|
||||||
|
|
||||||
|
tmp_handle = vfs_mkstemps (&tmp_vpath, path_element->class->name, name);
|
||||||
|
ino->localname = vfs_path_to_str (tmp_vpath);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
if (tmp_handle == -1)
|
if (tmp_handle == -1)
|
||||||
{
|
{
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
@ -1300,6 +1304,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
|
|||||||
int handle, n;
|
int handle, n;
|
||||||
off_t stat_size = ino->st.st_size;
|
off_t stat_size = ino->st.st_size;
|
||||||
vfs_file_handler_t fh;
|
vfs_file_handler_t fh;
|
||||||
|
vfs_path_t *tmp_vpath;
|
||||||
|
|
||||||
if ((MEDATA->flags & VFS_S_USETMP) == 0)
|
if ((MEDATA->flags & VFS_S_USETMP) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1309,7 +1314,9 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
|
|||||||
fh.ino = ino;
|
fh.ino = ino;
|
||||||
fh.handle = -1;
|
fh.handle = -1;
|
||||||
|
|
||||||
handle = vfs_mkstemps (&ino->localname, me->name, ino->ent->name);
|
handle = vfs_mkstemps (&tmp_vpath, me->name, ino->ent->name);
|
||||||
|
ino->localname = vfs_path_to_str (tmp_vpath);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
{
|
{
|
||||||
me->verrno = errno;
|
me->verrno = errno;
|
||||||
|
@ -79,6 +79,7 @@ static char *
|
|||||||
mc_def_getlocalcopy (const char *filename)
|
mc_def_getlocalcopy (const char *filename)
|
||||||
{
|
{
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
|
vfs_path_t *tmp_vpath = NULL;
|
||||||
int fdin = -1, fdout = -1;
|
int fdin = -1, fdout = -1;
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
char buffer[BUF_1K * 8];
|
char buffer[BUF_1K * 8];
|
||||||
@ -90,7 +91,7 @@ mc_def_getlocalcopy (const char *filename)
|
|||||||
if (fdin == -1)
|
if (fdin == -1)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
fdout = vfs_mkstemps (&tmp, "vfs", filename);
|
fdout = vfs_mkstemps (&tmp_vpath, "vfs", filename);
|
||||||
if (fdout == -1)
|
if (fdout == -1)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -105,26 +106,27 @@ mc_def_getlocalcopy (const char *filename)
|
|||||||
fdin = -1;
|
fdin = -1;
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (close (fdout) == -1)
|
i = close (fdout);
|
||||||
|
fdout = -1;
|
||||||
|
if (i == -1)
|
||||||
{
|
{
|
||||||
fdout = -1;
|
fdout = -1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc_stat (vpath, &mystat) != -1)
|
if (mc_stat (vpath, &mystat) != -1)
|
||||||
chmod (tmp, mystat.st_mode);
|
mc_chmod (tmp_vpath, mystat.st_mode);
|
||||||
vfs_path_free (vpath);
|
|
||||||
|
|
||||||
return tmp;
|
tmp = vfs_path_to_str (tmp_vpath);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
|
vfs_path_free (tmp_vpath);
|
||||||
if (fdout != -1)
|
if (fdout != -1)
|
||||||
close (fdout);
|
close (fdout);
|
||||||
if (fdin != -1)
|
if (fdin != -1)
|
||||||
mc_close (fdin);
|
mc_close (fdin);
|
||||||
g_free (tmp);
|
return tmp;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -763,7 +765,7 @@ mc_lseek (int fd, off_t offset, int whence)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
mc_mkstemps (char **pname, const char *prefix, const char *suffix)
|
mc_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *suffix)
|
||||||
{
|
{
|
||||||
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
static unsigned long value;
|
static unsigned long value;
|
||||||
@ -771,6 +773,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
|
|||||||
char *tmpbase;
|
char *tmpbase;
|
||||||
char *tmpname;
|
char *tmpname;
|
||||||
char *XXXXXX;
|
char *XXXXXX;
|
||||||
|
char *ret_path;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if (strchr (prefix, PATH_SEP) == NULL)
|
if (strchr (prefix, PATH_SEP) == NULL)
|
||||||
@ -784,7 +787,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, (char *) NULL);
|
tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, (char *) NULL);
|
||||||
*pname = tmpname;
|
ret_path = tmpname;
|
||||||
XXXXXX = &tmpname[strlen (tmpbase)];
|
XXXXXX = &tmpname[strlen (tmpbase)];
|
||||||
g_free (tmpbase);
|
g_free (tmpbase);
|
||||||
|
|
||||||
@ -814,6 +817,8 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
|
|||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
/* Successfully created. */
|
/* Successfully created. */
|
||||||
|
*pname_vpath = vfs_path_from_str (ret_path);
|
||||||
|
g_free (ret_path);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,8 +829,8 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Unsuccessful. Free the filename. */
|
/* Unsuccessful. Free the filename. */
|
||||||
g_free (tmpname);
|
g_free (ret_path);
|
||||||
*pname = NULL;
|
*pname_vpath = NULL;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -894,25 +899,30 @@ mc_tmpdir (void)
|
|||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
int test_fd;
|
int test_fd;
|
||||||
char *test_fn, *fallback_prefix;
|
char *fallback_prefix;
|
||||||
int fallback_ok = 0;
|
gboolean fallback_ok = FALSE;
|
||||||
|
vfs_path_t *test_vpath;
|
||||||
|
|
||||||
if (*error)
|
if (*error)
|
||||||
fprintf (stderr, error, buffer);
|
fprintf (stderr, error, buffer);
|
||||||
|
|
||||||
/* Test if sys_tmp is suitable for temporary files */
|
/* Test if sys_tmp is suitable for temporary files */
|
||||||
fallback_prefix = g_strdup_printf ("%s/mctest", sys_tmp);
|
fallback_prefix = g_strdup_printf ("%s/mctest", sys_tmp);
|
||||||
test_fd = mc_mkstemps (&test_fn, fallback_prefix, NULL);
|
test_fd = mc_mkstemps (&test_vpath, fallback_prefix, NULL);
|
||||||
g_free (fallback_prefix);
|
g_free (fallback_prefix);
|
||||||
if (test_fd != -1)
|
if (test_fd != -1)
|
||||||
{
|
{
|
||||||
|
char *test_fn;
|
||||||
|
|
||||||
|
test_fn = vfs_path_to_str (test_vpath);
|
||||||
close (test_fd);
|
close (test_fd);
|
||||||
test_fd = open (test_fn, O_RDONLY);
|
test_fd = open (test_fn, O_RDONLY);
|
||||||
|
g_free (test_fn);
|
||||||
if (test_fd != -1)
|
if (test_fd != -1)
|
||||||
{
|
{
|
||||||
close (test_fd);
|
close (test_fd);
|
||||||
unlink (test_fn);
|
unlink (test_fn);
|
||||||
fallback_ok = 1;
|
fallback_ok = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,6 +938,7 @@ mc_tmpdir (void)
|
|||||||
g_snprintf (buffer, sizeof (buffer), "%s", "/dev/null/");
|
g_snprintf (buffer, sizeof (buffer), "%s", "/dev/null/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vfs_path_free (test_vpath);
|
||||||
fprintf (stderr, "%s\n", _("Press any key to continue..."));
|
fprintf (stderr, "%s\n", _("Press any key to continue..."));
|
||||||
getc (stdin);
|
getc (stdin);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ vfs_findgid (const char *gname)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
vfs_mkstemps (char **pname, const char *prefix, const char *param_basename)
|
vfs_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *param_basename)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
char *suffix, *q;
|
char *suffix, *q;
|
||||||
@ -197,7 +197,7 @@ vfs_mkstemps (char **pname, const char *prefix, const char *param_basename)
|
|||||||
}
|
}
|
||||||
*q = 0;
|
*q = 0;
|
||||||
|
|
||||||
fd = mc_mkstemps (pname, prefix, suffix);
|
fd = mc_mkstemps (pname_vpath, prefix, suffix);
|
||||||
g_free (suffix);
|
g_free (suffix);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ int vfs_findgid (const char *name);
|
|||||||
vfs_path_element_t *vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags);
|
vfs_path_element_t *vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags);
|
||||||
int vfs_split_text (char *p);
|
int vfs_split_text (char *p);
|
||||||
|
|
||||||
int vfs_mkstemps (char **pname, const char *prefix, const char *basename);
|
int vfs_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *basename);
|
||||||
void vfs_die (const char *msg);
|
void vfs_die (const char *msg);
|
||||||
char *vfs_get_password (const char *msg);
|
char *vfs_get_password (const char *msg);
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ int mc_open (const vfs_path_t * vpath, int flags, ...);
|
|||||||
char *mc_get_current_wd (char *buffer, size_t bufsize);
|
char *mc_get_current_wd (char *buffer, size_t bufsize);
|
||||||
char *mc_getlocalcopy (const char *pathname);
|
char *mc_getlocalcopy (const char *pathname);
|
||||||
int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed);
|
int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed);
|
||||||
int mc_mkstemps (char **pname, const char *prefix, const char *suffix);
|
int mc_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *suffix);
|
||||||
|
|
||||||
/* Creating temporary files safely */
|
/* Creating temporary files safely */
|
||||||
const char *mc_tmpdir (void);
|
const char *mc_tmpdir (void);
|
||||||
|
@ -152,14 +152,17 @@ dview_select_encoding (WDiff * dview)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
rewrite_backup_content (const char *from_file_name, const char *to_file_name)
|
rewrite_backup_content (const vfs_path_t * from_file_name_vpath, const char *to_file_name)
|
||||||
{
|
{
|
||||||
FILE *backup_fd;
|
FILE *backup_fd;
|
||||||
char *contents;
|
char *contents;
|
||||||
gsize length;
|
gsize length;
|
||||||
|
const char *from_file_name;
|
||||||
|
|
||||||
|
from_file_name = vfs_path_get_by_index (from_file_name_vpath, -1)->path;
|
||||||
if (!g_file_get_contents (from_file_name, &contents, &length, NULL))
|
if (!g_file_get_contents (from_file_name, &contents, &length, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -194,7 +197,7 @@ static int
|
|||||||
open_temp (void **name)
|
open_temp (void **name)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char *diff_file_name = NULL;
|
vfs_path_t *diff_file_name = NULL;
|
||||||
|
|
||||||
fd = mc_mkstemps (&diff_file_name, "mcdiff", NULL);
|
fd = mc_mkstemps (&diff_file_name, "mcdiff", NULL);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
@ -203,7 +206,8 @@ open_temp (void **name)
|
|||||||
_("Cannot create temporary diff file\n%s"), unix_error_string (errno));
|
_("Cannot create temporary diff file\n%s"), unix_error_string (errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*name = diff_file_name;
|
*name = vfs_path_to_str (diff_file_name);
|
||||||
|
vfs_path_free (diff_file_name);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2198,7 +2202,7 @@ do_merge_hunk (WDiff * dview)
|
|||||||
{
|
{
|
||||||
int merge_file_fd;
|
int merge_file_fd;
|
||||||
FILE *merge_file;
|
FILE *merge_file;
|
||||||
char *merge_file_name = NULL;
|
vfs_path_t *merge_file_name_vpath = NULL;
|
||||||
|
|
||||||
if (!dview->merged)
|
if (!dview->merged)
|
||||||
{
|
{
|
||||||
@ -2213,7 +2217,7 @@ do_merge_hunk (WDiff * dview)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
merge_file_fd = mc_mkstemps (&merge_file_name, "mcmerge", NULL);
|
merge_file_fd = mc_mkstemps (&merge_file_name_vpath, "mcmerge", NULL);
|
||||||
if (merge_file_fd == -1)
|
if (merge_file_fd == -1)
|
||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot create temporary merge file\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot create temporary merge file\n%s"),
|
||||||
@ -2237,9 +2241,9 @@ do_merge_hunk (WDiff * dview)
|
|||||||
}
|
}
|
||||||
fflush (merge_file);
|
fflush (merge_file);
|
||||||
fclose (merge_file);
|
fclose (merge_file);
|
||||||
res = rewrite_backup_content (merge_file_name, dview->file[0]);
|
res = rewrite_backup_content (merge_file_name_vpath, dview->file[0]);
|
||||||
unlink (merge_file_name);
|
mc_unlink (merge_file_name_vpath);
|
||||||
g_free (merge_file_name);
|
vfs_path_free (merge_file_name_vpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "lib/search.h" /* mc_search_type_t */
|
#include "lib/search.h" /* mc_search_type_t */
|
||||||
#include "lib/widget.h" /* cb_ret_t */
|
#include "lib/widget.h" /* cb_ret_t */
|
||||||
|
#include "lib/vfs/vfs.h" /* vfs_path_t */
|
||||||
|
|
||||||
#include "edit.h"
|
#include "edit.h"
|
||||||
|
|
||||||
@ -219,7 +220,7 @@ void edit_push_redo_action (WEdit * edit, long c, ...);
|
|||||||
void edit_push_key_press (WEdit * edit);
|
void edit_push_key_press (WEdit * edit);
|
||||||
void edit_insert_ahead (WEdit * edit, int c);
|
void edit_insert_ahead (WEdit * edit, int c);
|
||||||
long edit_write_stream (WEdit * edit, FILE * f);
|
long edit_write_stream (WEdit * edit, FILE * f);
|
||||||
char *edit_get_write_filter (const char *writename, const char *filename);
|
char *edit_get_write_filter (const vfs_path_t * write_name_vpath, const char *filename);
|
||||||
int edit_save_confirm_cmd (WEdit * edit);
|
int edit_save_confirm_cmd (WEdit * edit);
|
||||||
int edit_save_as_cmd (WEdit * edit);
|
int edit_save_as_cmd (WEdit * edit);
|
||||||
WEdit *edit_init (WEdit * edit, int y, int x, int lines, int cols, const char *filename, long line);
|
WEdit *edit_init (WEdit * edit, int y, int x, int lines, int cols, const char *filename, long line);
|
||||||
|
@ -1966,16 +1966,18 @@ edit_get_utf (WEdit * edit, long byte_index, int *char_width)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
edit_get_write_filter (const char *write_name, const char *filename)
|
edit_get_write_filter (const vfs_path_t * write_name_vpath, const char *filename)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *p, *writename;
|
char *p, *writename;
|
||||||
|
vfs_path_element_t *path_element;
|
||||||
|
|
||||||
i = edit_find_filter (filename);
|
i = edit_find_filter (filename);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
writename = name_quote (write_name, 0);
|
path_element = vfs_path_get_by_index (write_name_vpath, -1);
|
||||||
|
writename = name_quote (path_element->path, 0);
|
||||||
p = g_strdup_printf (all_filters[i].write, writename);
|
p = g_strdup_printf (all_filters[i].write, writename);
|
||||||
g_free (writename);
|
g_free (writename);
|
||||||
return p;
|
return p;
|
||||||
|
@ -121,11 +121,10 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
char *p;
|
char *p;
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
long filelen = 0;
|
long filelen = 0;
|
||||||
char *savename = 0;
|
|
||||||
gchar *real_filename;
|
gchar *real_filename;
|
||||||
int this_save_mode, fd = -1;
|
int this_save_mode, fd = -1;
|
||||||
vfs_path_t *real_filename_vpath;
|
vfs_path_t *real_filename_vpath;
|
||||||
vfs_path_t *savename_vpath;
|
vfs_path_t *savename_vpath = NULL;
|
||||||
|
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return 0;
|
return 0;
|
||||||
@ -215,11 +214,11 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
savedir = g_strdup (".");
|
savedir = g_strdup (".");
|
||||||
saveprefix = concat_dir_and_file (savedir, "cooledit");
|
saveprefix = mc_build_filename (savedir, "cooledit", NULL);
|
||||||
g_free (savedir);
|
g_free (savedir);
|
||||||
fd = mc_mkstemps (&savename, saveprefix, NULL);
|
fd = mc_mkstemps (&savename_vpath, saveprefix, NULL);
|
||||||
g_free (saveprefix);
|
g_free (saveprefix);
|
||||||
if (!savename)
|
if (savename_vpath == NULL)
|
||||||
{
|
{
|
||||||
g_free (real_filename);
|
g_free (real_filename);
|
||||||
vfs_path_free (real_filename_vpath);
|
vfs_path_free (real_filename_vpath);
|
||||||
@ -233,9 +232,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
close (fd);
|
close (fd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
savename = g_strdup (real_filename);
|
savename_vpath = vfs_path_from_str (real_filename);
|
||||||
|
|
||||||
savename_vpath = vfs_path_from_str (savename);
|
|
||||||
|
|
||||||
(void) mc_chown (savename_vpath, edit->stat1.st_uid, edit->stat1.st_gid);
|
(void) mc_chown (savename_vpath, edit->stat1.st_uid, edit->stat1.st_gid);
|
||||||
(void) mc_chmod (savename_vpath, edit->stat1.st_mode);
|
(void) mc_chmod (savename_vpath, edit->stat1.st_mode);
|
||||||
@ -245,7 +242,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
goto error_save;
|
goto error_save;
|
||||||
|
|
||||||
/* pipe save */
|
/* pipe save */
|
||||||
p = edit_get_write_filter (savename, real_filename);
|
p = edit_get_write_filter (savename_vpath, real_filename);
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
@ -328,19 +325,19 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
goto error_save;
|
goto error_save;
|
||||||
|
|
||||||
/* Update the file information, especially the mtime. */
|
/* Update the file information, especially the mtime. */
|
||||||
savename_vpath = vfs_path_from_str (savename);
|
|
||||||
if (mc_stat (savename_vpath, &edit->stat1) == -1)
|
if (mc_stat (savename_vpath, &edit->stat1) == -1)
|
||||||
goto error_save;
|
goto error_save;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* change line breaks */
|
{ /* change line breaks */
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
vfs_path_element_t *path_element;
|
||||||
|
|
||||||
mc_close (fd);
|
mc_close (fd);
|
||||||
|
|
||||||
file = (FILE *) fopen (savename, "w");
|
path_element = vfs_path_get_by_index (savename_vpath, -1);
|
||||||
|
file = (FILE *) fopen (path_element->path, "w");
|
||||||
if (file)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
filelen = edit_write_stream (edit, file);
|
filelen = edit_write_stream (edit, file);
|
||||||
fclose (file);
|
fclose (file);
|
||||||
@ -349,7 +346,7 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
msg = g_strdup_printf (_("Cannot open file for writing: %s"), savename);
|
msg = g_strdup_printf (_("Cannot open file for writing: %s"), path_element->path);
|
||||||
edit_error_dialog (_("Error"), msg);
|
edit_error_dialog (_("Error"), msg);
|
||||||
g_free (msg);
|
g_free (msg);
|
||||||
goto error_save;
|
goto error_save;
|
||||||
@ -375,8 +372,8 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
if (this_save_mode != EDIT_QUICK_SAVE)
|
if (this_save_mode != EDIT_QUICK_SAVE)
|
||||||
if (mc_rename (savename_vpath, real_filename_vpath) == -1)
|
if (mc_rename (savename_vpath, real_filename_vpath) == -1)
|
||||||
goto error_save;
|
goto error_save;
|
||||||
|
|
||||||
g_free (real_filename);
|
g_free (real_filename);
|
||||||
g_free (savename);
|
|
||||||
vfs_path_free (real_filename_vpath);
|
vfs_path_free (real_filename_vpath);
|
||||||
vfs_path_free (savename_vpath);
|
vfs_path_free (savename_vpath);
|
||||||
return 1;
|
return 1;
|
||||||
@ -386,7 +383,6 @@ edit_save_file (WEdit * edit, const char *filename)
|
|||||||
* mc_unlink (savename);
|
* mc_unlink (savename);
|
||||||
*/
|
*/
|
||||||
g_free (real_filename);
|
g_free (real_filename);
|
||||||
g_free (savename);
|
|
||||||
vfs_path_free (real_filename_vpath);
|
vfs_path_free (real_filename_vpath);
|
||||||
vfs_path_free (savename_vpath);
|
vfs_path_free (savename_vpath);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -92,7 +92,7 @@ static char *data = NULL;
|
|||||||
static void
|
static void
|
||||||
exec_extension (const char *filename, const char *lc_data, int *move_dir, int start_line)
|
exec_extension (const char *filename, const char *lc_data, int *move_dir, int start_line)
|
||||||
{
|
{
|
||||||
char *file_name;
|
vfs_path_t *file_name_vpath;
|
||||||
int cmd_file_fd;
|
int cmd_file_fd;
|
||||||
FILE *cmd_file;
|
FILE *cmd_file;
|
||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
@ -119,10 +119,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
vpath = vfs_path_from_str (filename);
|
vpath = vfs_path_from_str (filename);
|
||||||
|
|
||||||
/* Avoid making a local copy if we are doing a cd */
|
/* Avoid making a local copy if we are doing a cd */
|
||||||
if (!vfs_file_is_local (vpath))
|
do_local_copy = vfs_file_is_local (vpath) ? 0 : 1;
|
||||||
do_local_copy = 1;
|
|
||||||
else
|
|
||||||
do_local_copy = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All commands should be run in /bin/sh regardless of user shell.
|
* All commands should be run in /bin/sh regardless of user shell.
|
||||||
@ -130,13 +127,13 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
* Sometimes it's not needed (e.g. for %cd and %view commands),
|
* Sometimes it's not needed (e.g. for %cd and %view commands),
|
||||||
* but it's easier to create it anyway.
|
* but it's easier to create it anyway.
|
||||||
*/
|
*/
|
||||||
cmd_file_fd = mc_mkstemps (&file_name, "mcext", SCRIPT_SUFFIX);
|
cmd_file_fd = mc_mkstemps (&file_name_vpath, "mcext", SCRIPT_SUFFIX);
|
||||||
|
|
||||||
if (cmd_file_fd == -1)
|
if (cmd_file_fd == -1)
|
||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR,
|
message (D_ERROR, MSG_ERROR,
|
||||||
_("Cannot create temporary command file\n%s"), unix_error_string (errno));
|
_("Cannot create temporary command file\n%s"), unix_error_string (errno));
|
||||||
return;
|
goto ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_file = fdopen (cmd_file_fd, "w");
|
cmd_file = fdopen (cmd_file_fd, "w");
|
||||||
@ -157,15 +154,13 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
{
|
{
|
||||||
/* User canceled */
|
/* User canceled */
|
||||||
fclose (cmd_file);
|
fclose (cmd_file);
|
||||||
unlink (file_name);
|
mc_unlink (file_name_vpath);
|
||||||
if (localcopy)
|
if (localcopy)
|
||||||
{
|
{
|
||||||
mc_ungetlocalcopy (filename, localcopy, 0);
|
mc_ungetlocalcopy (filename, localcopy, 0);
|
||||||
g_free (localcopy);
|
g_free (localcopy);
|
||||||
}
|
}
|
||||||
g_free (file_name);
|
goto ret;
|
||||||
vfs_path_free (vpath);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
fputs (parameter, cmd_file);
|
fputs (parameter, cmd_file);
|
||||||
written_nonspace = 1;
|
written_nonspace = 1;
|
||||||
@ -229,14 +224,13 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
if (do_local_copy)
|
if (do_local_copy)
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath_local;
|
vfs_path_t *vpath_local;
|
||||||
|
|
||||||
localcopy = mc_getlocalcopy (filename);
|
localcopy = mc_getlocalcopy (filename);
|
||||||
if (localcopy == NULL)
|
if (localcopy == NULL)
|
||||||
{
|
{
|
||||||
fclose (cmd_file);
|
fclose (cmd_file);
|
||||||
unlink (file_name);
|
mc_unlink (file_name_vpath);
|
||||||
g_free (file_name);
|
goto ret;
|
||||||
vfs_path_free (vpath);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
vpath_local = vfs_path_from_str (localcopy);
|
vpath_local = vfs_path_from_str (localcopy);
|
||||||
mc_stat (vpath_local, &mystat);
|
mc_stat (vpath_local, &mystat);
|
||||||
@ -247,6 +241,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
vfs_path_element_t *path_element;
|
vfs_path_element_t *path_element;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
path_element = vfs_path_get_by_index (vpath, -1);
|
||||||
text = quote_func (path_element->path, 0);
|
text = quote_func (path_element->path, 0);
|
||||||
}
|
}
|
||||||
@ -286,22 +281,32 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
* so we clean up after calling view().
|
* so we clean up after calling view().
|
||||||
*/
|
*/
|
||||||
if (!run_view)
|
if (!run_view)
|
||||||
|
{
|
||||||
|
char *file_name;
|
||||||
|
|
||||||
|
file_name = vfs_path_to_str (file_name_vpath);
|
||||||
fprintf (cmd_file, "\n/bin/rm -f %s\n", file_name);
|
fprintf (cmd_file, "\n/bin/rm -f %s\n", file_name);
|
||||||
|
g_free (file_name);
|
||||||
|
}
|
||||||
|
|
||||||
fclose (cmd_file);
|
fclose (cmd_file);
|
||||||
|
|
||||||
if ((run_view && !written_nonspace) || is_cd)
|
if ((run_view && !written_nonspace) || is_cd)
|
||||||
{
|
{
|
||||||
unlink (file_name);
|
mc_unlink (file_name_vpath);
|
||||||
g_free (file_name);
|
vfs_path_free (file_name_vpath);
|
||||||
file_name = NULL;
|
file_name_vpath = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
char *file_name;
|
||||||
|
|
||||||
|
file_name = vfs_path_to_str (file_name_vpath);
|
||||||
/* Set executable flag on the command file ... */
|
/* Set executable flag on the command file ... */
|
||||||
chmod (file_name, S_IRWXU);
|
mc_chmod (file_name_vpath, S_IRWXU);
|
||||||
/* ... but don't rely on it - run /bin/sh explicitly */
|
/* ... but don't rely on it - run /bin/sh explicitly */
|
||||||
cmd = g_strconcat ("/bin/sh ", file_name, (char *) NULL);
|
cmd = g_strconcat ("/bin/sh ", file_name, (char *) NULL);
|
||||||
|
g_free (file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run_view)
|
if (run_view)
|
||||||
@ -321,7 +326,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
if (written_nonspace)
|
if (written_nonspace)
|
||||||
{
|
{
|
||||||
ret = mcview_viewer (cmd, filename, start_line);
|
ret = mcview_viewer (cmd, filename, start_line);
|
||||||
unlink (file_name);
|
mc_unlink (file_name_vpath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret = mcview_viewer (NULL, filename, start_line);
|
ret = mcview_viewer (NULL, filename, start_line);
|
||||||
@ -375,7 +380,6 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (file_name);
|
|
||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
|
|
||||||
if (localcopy)
|
if (localcopy)
|
||||||
@ -388,6 +392,8 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
|||||||
vfs_path_free (vpath_local);
|
vfs_path_free (vpath_local);
|
||||||
g_free (localcopy);
|
g_free (localcopy);
|
||||||
}
|
}
|
||||||
|
ret:
|
||||||
|
vfs_path_free (file_name_vpath);
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ execute_menu_command (WEdit * edit_widget, const char *commands, gboolean show_p
|
|||||||
gboolean do_quote = FALSE;
|
gboolean do_quote = FALSE;
|
||||||
char lc_prompt[80];
|
char lc_prompt[80];
|
||||||
int col;
|
int col;
|
||||||
char *file_name;
|
vfs_path_t *file_name_vpath;
|
||||||
int run_view = 0;
|
int run_view = 0;
|
||||||
|
|
||||||
/* Skip menu entry title line */
|
/* Skip menu entry title line */
|
||||||
@ -428,12 +428,13 @@ execute_menu_command (WEdit * edit_widget, const char *commands, gboolean show_p
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_file_fd = mc_mkstemps (&file_name, "mcusr", SCRIPT_SUFFIX);
|
cmd_file_fd = mc_mkstemps (&file_name_vpath, "mcusr", SCRIPT_SUFFIX);
|
||||||
|
|
||||||
if (cmd_file_fd == -1)
|
if (cmd_file_fd == -1)
|
||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot create temporary command file\n%s"),
|
message (D_ERROR, MSG_ERROR, _("Cannot create temporary command file\n%s"),
|
||||||
unix_error_string (errno));
|
unix_error_string (errno));
|
||||||
|
vfs_path_free (file_name_vpath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cmd_file = fdopen (cmd_file_fd, "w");
|
cmd_file = fdopen (cmd_file_fd, "w");
|
||||||
@ -466,8 +467,8 @@ execute_menu_command (WEdit * edit_widget, const char *commands, gboolean show_p
|
|||||||
{
|
{
|
||||||
/* User canceled */
|
/* User canceled */
|
||||||
fclose (cmd_file);
|
fclose (cmd_file);
|
||||||
unlink (file_name);
|
mc_unlink (file_name_vpath);
|
||||||
g_free (file_name);
|
vfs_path_free (file_name_vpath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (do_quote)
|
if (do_quote)
|
||||||
@ -528,17 +529,25 @@ execute_menu_command (WEdit * edit_widget, const char *commands, gboolean show_p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (cmd_file);
|
fclose (cmd_file);
|
||||||
chmod (file_name, S_IRWXU);
|
mc_chmod (file_name_vpath, S_IRWXU);
|
||||||
if (run_view)
|
if (run_view)
|
||||||
{
|
{
|
||||||
|
char *file_name;
|
||||||
|
|
||||||
|
file_name = vfs_path_to_str (file_name_vpath);
|
||||||
mcview_viewer (file_name, NULL, 0);
|
mcview_viewer (file_name, NULL, 0);
|
||||||
|
g_free (file_name);
|
||||||
dialog_switch_process_pending ();
|
dialog_switch_process_pending ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* execute the command indirectly to allow execution even
|
/* execute the command indirectly to allow execution even
|
||||||
* on no-exec filesystems. */
|
* on no-exec filesystems. */
|
||||||
char *cmd = g_strconcat ("/bin/sh ", file_name, (char *) NULL);
|
char *file_name, *cmd;
|
||||||
|
|
||||||
|
file_name = vfs_path_to_str (file_name_vpath);
|
||||||
|
cmd = g_strconcat ("/bin/sh ", file_name, (char *) NULL);
|
||||||
|
g_free (file_name);
|
||||||
if (!show_prompt)
|
if (!show_prompt)
|
||||||
{
|
{
|
||||||
if (system (cmd) == -1)
|
if (system (cmd) == -1)
|
||||||
@ -550,8 +559,8 @@ execute_menu_command (WEdit * edit_widget, const char *commands, gboolean show_p
|
|||||||
}
|
}
|
||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
}
|
}
|
||||||
unlink (file_name);
|
mc_unlink (file_name_vpath);
|
||||||
g_free (file_name);
|
vfs_path_free (file_name_vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -922,23 +922,26 @@ extfs_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
|
|
||||||
if (entry->inode->local_filename == NULL)
|
if (entry->inode->local_filename == NULL)
|
||||||
{
|
{
|
||||||
|
vfs_path_t *local_filename_vpath;
|
||||||
char *local_filename;
|
char *local_filename;
|
||||||
|
|
||||||
local_handle = vfs_mkstemps (&local_filename, "extfs", entry->name);
|
local_handle = vfs_mkstemps (&local_filename_vpath, "extfs", entry->name);
|
||||||
|
|
||||||
if (local_handle == -1)
|
if (local_handle == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
close (local_handle);
|
close (local_handle);
|
||||||
|
local_filename = vfs_path_get_by_index (local_filename_vpath, -1)->path;
|
||||||
|
|
||||||
if (!created && ((flags & O_TRUNC) == 0)
|
if (!created && ((flags & O_TRUNC) == 0)
|
||||||
&& extfs_cmd (" copyout ", archive, entry, local_filename))
|
&& extfs_cmd (" copyout ", archive, entry, local_filename))
|
||||||
{
|
{
|
||||||
unlink (local_filename);
|
unlink (local_filename);
|
||||||
g_free (local_filename);
|
vfs_path_free (local_filename_vpath);
|
||||||
my_errno = EIO;
|
my_errno = EIO;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
entry->inode->local_filename = local_filename;
|
entry->inode->local_filename = g_strdup (local_filename);
|
||||||
|
vfs_path_free (local_filename_vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
local_handle = open (entry->inode->local_filename, NO_LINEAR (flags), mode);
|
local_handle = open (entry->inode->local_filename, NO_LINEAR (flags), mode);
|
||||||
|
@ -1522,10 +1522,17 @@ fish_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t m
|
|||||||
|
|
||||||
if (!fh->ino->localname)
|
if (!fh->ino->localname)
|
||||||
{
|
{
|
||||||
int tmp_handle = vfs_mkstemps (&fh->ino->localname, me->name,
|
vfs_path_t *vpath;
|
||||||
fh->ino->ent->name);
|
int tmp_handle;
|
||||||
|
|
||||||
|
tmp_handle = vfs_mkstemps (&vpath, me->name, fh->ino->ent->name);
|
||||||
if (tmp_handle == -1)
|
if (tmp_handle == -1)
|
||||||
|
{
|
||||||
|
vfs_path_free (vpath);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
|
fh->ino->localname = vfs_path_to_str (vpath);
|
||||||
|
vfs_path_free (vpath);
|
||||||
close (tmp_handle);
|
close (tmp_handle);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2143,11 +2143,18 @@ ftpfs_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t
|
|||||||
{
|
{
|
||||||
if (!fh->ino->localname)
|
if (!fh->ino->localname)
|
||||||
{
|
{
|
||||||
int handle = vfs_mkstemps (&fh->ino->localname, me->name,
|
vfs_path_t *vpath;
|
||||||
fh->ino->ent->name);
|
int handle;
|
||||||
|
|
||||||
|
handle = vfs_mkstemps (&vpath, me->name, fh->ino->ent->name);
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
|
{
|
||||||
|
vfs_path_free (vpath);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
close (handle);
|
close (handle);
|
||||||
|
fh->ino->localname = vfs_path_to_str (vpath);
|
||||||
|
vfs_path_free (vpath);
|
||||||
ftp->append = flags & O_APPEND;
|
ftp->append = flags & O_APPEND;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -120,7 +120,7 @@ cachedfile_compare (const void *a, const void *b)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sfs_vfmake (const vfs_path_t * vpath, char *cache)
|
sfs_vfmake (const vfs_path_t * vpath, vfs_path_t * cache_vpath)
|
||||||
{
|
{
|
||||||
int w;
|
int w;
|
||||||
char pad[10240];
|
char pad[10240];
|
||||||
@ -178,8 +178,13 @@ sfs_vfmake (const vfs_path_t * vpath, char *cache)
|
|||||||
ptr = path_element->path;
|
ptr = path_element->path;
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
ptr = cache;
|
{
|
||||||
|
vfs_path_element_t *tmp_path_element;
|
||||||
|
|
||||||
|
tmp_path_element = vfs_path_get_by_index (cache_vpath, -1);
|
||||||
|
ptr = tmp_path_element->path;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case '%':
|
case '%':
|
||||||
COPY_CHAR;
|
COPY_CHAR;
|
||||||
continue;
|
continue;
|
||||||
@ -214,7 +219,7 @@ sfs_redirect (const vfs_path_t * vpath)
|
|||||||
{
|
{
|
||||||
GSList *cur;
|
GSList *cur;
|
||||||
cachedfile *cf;
|
cachedfile *cf;
|
||||||
char *cache;
|
vfs_path_t *cache_vpath;
|
||||||
int handle;
|
int handle;
|
||||||
vfs_path_element_t *path_element;
|
vfs_path_element_t *path_element;
|
||||||
char *path = vfs_path_to_str (vpath);
|
char *path = vfs_path_to_str (vpath);
|
||||||
@ -230,26 +235,27 @@ sfs_redirect (const vfs_path_t * vpath)
|
|||||||
return cf->cache;
|
return cf->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle = vfs_mkstemps (&cache, "sfs", path_element->path);
|
handle = vfs_mkstemps (&cache_vpath, "sfs", path_element->path);
|
||||||
|
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
return "/SOMEONE_PLAYING_DIRTY_TMP_TRICKS_ON_US";
|
return "/SOMEONE_PLAYING_DIRTY_TMP_TRICKS_ON_US";
|
||||||
|
|
||||||
close (handle);
|
close (handle);
|
||||||
|
|
||||||
if (sfs_vfmake (vpath, cache) == 0)
|
if (sfs_vfmake (vpath, cache_vpath) == 0)
|
||||||
{
|
{
|
||||||
cf = g_new (cachedfile, 1);
|
cf = g_new (cachedfile, 1);
|
||||||
cf->name = vfs_path_to_str (vpath);
|
cf->name = vfs_path_to_str (vpath);
|
||||||
cf->cache = cache;
|
cf->cache = vfs_path_to_str (cache_vpath);
|
||||||
head = g_slist_prepend (head, cf);
|
head = g_slist_prepend (head, cf);
|
||||||
|
vfs_path_free (cache_vpath);
|
||||||
|
|
||||||
vfs_stamp_create (&vfs_sfs_ops, (cachedfile *) head->data);
|
vfs_stamp_create (&vfs_sfs_ops, (cachedfile *) head->data);
|
||||||
return cache;
|
return cf->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink (cache);
|
mc_unlink (cache_vpath);
|
||||||
g_free (cache);
|
vfs_path_free (cache_vpath);
|
||||||
return "/I_MUST_NOT_EXIST";
|
return "/I_MUST_NOT_EXIST";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,11 +50,18 @@ struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3;
|
|||||||
static void
|
static void
|
||||||
setup (void)
|
setup (void)
|
||||||
{
|
{
|
||||||
|
str_init_strings (NULL);
|
||||||
|
|
||||||
|
vfs_init ();
|
||||||
|
init_localfs ();
|
||||||
|
vfs_setup_work_dir ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
teardown (void)
|
teardown (void)
|
||||||
{
|
{
|
||||||
|
vfs_shut ();
|
||||||
|
str_uninit_strings ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -79,16 +86,20 @@ END_TEST
|
|||||||
|
|
||||||
START_TEST (test_mc_mkstemps)
|
START_TEST (test_mc_mkstemps)
|
||||||
{
|
{
|
||||||
char *pname = NULL;
|
vfs_path_t *pname_vpath = NULL;
|
||||||
|
char *pname;
|
||||||
char *begin_pname;
|
char *begin_pname;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = mc_mkstemps (&pname, "mctest-", NULL);
|
fd = mc_mkstemps (&pname_vpath, "mctest-", NULL);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
fail ("\nerror creating temp file!\n");
|
fail ("\nerror creating temp file!\n");
|
||||||
}
|
}
|
||||||
|
pname = vfs_path_to_str (pname_vpath);
|
||||||
|
vfs_path_free (pname_vpath);
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
fail_unless (
|
fail_unless (
|
||||||
g_file_test (pname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR),
|
g_file_test (pname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR),
|
||||||
"\nNo such file: %s\n", pname
|
"\nNo such file: %s\n", pname
|
||||||
|
Loading…
Reference in New Issue
Block a user