if (!test && trash)
{
tr_logAddInfo ("Deleting input .torrent file \"%s\"", file);
- if (remove (filename))
+ if (tr_remove (filename))
tr_logAddError ("Error deleting .torrent file: %s", tr_strerror (errno));
}
else
{
char * new_filename = tr_strdup_printf ("%s.added", filename);
- rename (filename, new_filename);
+ tr_rename (filename, new_filename);
tr_free (new_filename);
}
}
/* cleanup */
if (pidfile_created)
- remove (pid_filename);
+ tr_remove (pid_filename);
tr_variantFree (&settings);
return 0;
}
tr_mkdirp (dir, 0700);
tr_free (dir);
- remove (path);
+ tr_remove (path);
fp = fopen (path, "w+");
fprintf (fp, "%s", contents);
fclose (fp);
if (verbose)
fprintf (stderr, "cleanup: removing %s\n", killme);
- remove (killme);
+ tr_remove (killme);
}
}
{
char * o = tr_buildPath (oldDir, name, NULL);
char * n = tr_buildPath (newDir, name, NULL);
- rename (o, n);
+ tr_rename (o, n);
++count;
tr_free (n);
tr_free (o);
#include <assert.h>
#include <errno.h>
-#include <stdio.h> /* remove() */
+#include <stdio.h> /* fopen() */
#include <string.h> /* strcmp() */
#include <stdio.h>
assert (rv == 0);
tr_free (dir);
- remove (path);
+ tr_remove (path);
fp = fopen (path, "wb");
fprintf (fp, "%s", str);
fclose (fp);
/* remove the directory Felidae/Felinae/Felis/catus */
str = tr_torrentFindFile (tor, 1);
check (str != NULL);
- remove (str);
+ tr_remove (str);
tr_free (str);
str = tr_torrentFindFile (tor, 2);
check (str != NULL);
- remove (str);
+ tr_remove (str);
tmp = tr_dirname (str);
- remove (tmp);
+ tr_remove (tmp);
tr_free (tmp);
tr_free (str);
sync ();
tr_blocklistFile * b;
old = tr_strdup_printf ("%s.old", binname);
- remove (old);
- rename (binname, old);
+ tr_remove (old);
+ tr_rename (binname, old);
b = tr_blocklistFileNew (binname, isEnabled);
if (tr_blocklistFileSetContent (b, path) > 0)
{
- remove (old);
+ tr_remove (old);
}
else
{
- remove (binname);
- rename (old, binname);
+ tr_remove (binname);
+ tr_rename (old, binname);
}
tr_blocklistFileFree (b);
*/
#include <assert.h>
-#include <stdio.h> /* remove () */
#include <string.h> /* memcpy (), memset (), memcmp () */
#include <event2/buffer.h>
int infoDictLength;
/* remove any old .torrent and .resume files */
- remove (path);
+ tr_remove (path);
tr_torrentRemoveResume (tor);
dbgmsg (tor, "Saving completed metadata to \"%s\"", path);
#include <stdarg.h>
#include <string.h> /* memcmp */
#include <stdlib.h> /* qsort */
-#include <stdio.h> /* remove () */
#include <event2/util.h> /* evutil_vsnprintf () */
if (!stat (filename, &sb) && S_ISDIR (sb.st_mode))
removeEmptyFoldersAndJunkFiles (filename);
else if (isJunkFile (d->d_name))
- remove (filename);
+ tr_remove (filename);
tr_free (filename);
}
}
- remove (folder);
+ tr_remove (folder);
closedir (odir);
}
}
char * oldpath = tr_buildPath (base, sub, NULL);
char * newpath = tr_buildPath (base, f->name, NULL);
- if (rename (oldpath, newpath))
+ if (tr_rename (oldpath, newpath))
tr_logAddTorErr (tor, "Error moving \"%s\" to \"%s\": %s", oldpath, newpath, tr_strerror (errno));
tr_free (newpath);
int rv;
tmp = errno;
- rv = rename (src, tgt);
+ rv = tr_rename (src, tgt);
if (rv != 0)
error = errno;
errno = tmp;
/* they might be on the same filesystem... */
{
- const int i = rename (oldpath, newpath);
+ const int i = tr_rename (oldpath, newpath);
if (renamed != NULL)
*renamed = i == 0;
if (!i)
return 0;
}
+int
+tr_rename (const char * oldpath, const char * newpath)
+{
+ /* FIXME: needs win32 utf-16 support */
+
+ return rename (oldpath, newpath);
+}
+
+int
+tr_remove (const char * pathname)
+{
+ /* FIXME: needs win32 utf-16 support */
+
+ return remove (pathname);
+}
+
bool
tr_is_same_file (const char * filename1, const char * filename2)
{
int tr_moveFile (const char * oldpath, const char * newpath,
bool * renamed) TR_GNUC_NONNULL (1,2);
+/** @brief Portability wrapper for rename () */
+int tr_rename (const char * oldpath_utf8, const char * newpath_utf8);
+
+/** @brief Portability wrapper for remove () */
+int tr_remove (const char * pathname_utf8);
+
/** @brief Test to see if the two filenames point to the same file. */
bool tr_is_same_file (const char * filename1, const char * filename2);
{
tr_close_file (fd);
-#ifdef WIN32
- if (MoveFileEx (tmp, filename, MOVEFILE_REPLACE_EXISTING))
-#else
- if (!rename (tmp, filename))
-#endif
+ if (!tr_rename (tmp, filename))
{
tr_logAddInfo (_("Saved \"%s\""), filename);
}