aboutsummaryrefslogtreecommitdiffhomepage
path: root/wutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'wutil.h')
-rw-r--r--wutil.h45
1 files changed, 25 insertions, 20 deletions
diff --git a/wutil.h b/wutil.h
index 347e7313..a1945c07 100644
--- a/wutil.h
+++ b/wutil.h
@@ -16,6 +16,7 @@
#include <stdarg.h>
#include <string>
#include <utility>
+#include <stdint.h>
#include "common.h"
/**
@@ -37,14 +38,6 @@ FILE *wfopen(const wcstring &path, const char *mode);
/** Sets CLO_EXEC on a given fd */
bool set_cloexec(int fd);
-/**
- Wide character version of freopen().
-*/
-FILE *wfreopen(const wcstring &path, const char *mode, FILE *stream);
-
-/** Wide character version of open(). */
-int wopen(const wcstring &pathname, int flags, mode_t mode = 0);
-
/** Wide character version of open() that also sets the close-on-exec flag (atomically when possible). */
int wopen_cloexec(const wcstring &pathname, int flags, mode_t mode = 0);
@@ -54,10 +47,6 @@ int make_fd_nonblocking(int fd);
/** Mark an fd as blocking; returns errno or 0 on success */
int make_fd_blocking(int fd);
-/** Wide character version of creat(). */
-int wcreat(const wcstring &pathname, mode_t mode);
-
-
/** Wide character version of opendir(). Note that opendir() is guaranteed to set close-on-exec by POSIX (hooray). */
DIR *wopendir(const wcstring &name);
@@ -84,7 +73,7 @@ int wunlink(const wcstring &pathname);
/**
Wide character version of perror().
*/
-void wperror(const wcstring &s);
+void wperror(const wchar_t *s);
/**
Async-safe version of perror().
@@ -141,11 +130,6 @@ std::wstring wbasename(const std::wstring &path);
const wchar_t *wgettext(const wchar_t *in);
/**
- Wide character version of getenv
-*/
-const wchar_t *wgetenv(const wcstring &name);
-
-/**
Wide character version of mkdir
*/
int wmkdir(const wcstring &dir, int mode);
@@ -158,8 +142,29 @@ int wrename(const wcstring &oldName, const wcstring &newName);
/** Like wcstol(), but fails on a value outside the range of an int */
int fish_wcstoi(const wchar_t *str, wchar_t ** endptr, int base);
-/** Class for representing a file's inode. We use this to detect and avoid symlink loops, among other things. */
-typedef std::pair<dev_t, ino_t> file_id_t;
+/** Class for representing a file's inode. We use this to detect and avoid symlink loops, among other things. While an inode / dev pair is sufficient to distinguish co-existing files, Linux seems to aggressively re-use inodes, so it cannot determine if a file has been deleted (ABA problem). Therefore we include richer information. */
+struct file_id_t
+{
+ dev_t device;
+ ino_t inode;
+ uint64_t size;
+ time_t change_seconds;
+ long change_nanoseconds;
+ uint32_t generation;
+
+ bool operator==(const file_id_t &rhs) const;
+ bool operator!=(const file_id_t &rhs) const;
+
+ // Used to permit these as keys in std::map
+ bool operator<(const file_id_t &rhs) const;
+
+ static file_id_t file_id_from_stat(const struct stat *buf);
+};
+
+file_id_t file_id_for_fd(int fd);
+file_id_t file_id_for_path(const wcstring &path);
+
+extern const file_id_t kInvalidFileID;
#endif