summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buffer.c2
-rw-r--r--main.c4
-rw-r--r--os-win.c6
-rw-r--r--os.h5
4 files changed, 16 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index c2f16b8..607f250 100644
--- a/buffer.c
+++ b/buffer.c
@@ -2459,7 +2459,7 @@ bool buffer_save(TextBuffer *buffer) {
success = false;
}
if (success) {
- if (rename(tmp_path, buffer->path) != 0) {
+ if (os_rename_overwrite(tmp_path, buffer->path) < 0) {
if (!buffer_has_error(buffer))
buffer_error(buffer, "Couldn't rename %s => %s.", tmp_path, buffer->path);
success = false;
diff --git a/main.c b/main.c
index 766a612..9d85a49 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,9 @@
/*
@TODO:
+- set commit authors correctly
+- finish fixing buffer backup (windows)
+- fix calls to WideCharToMultiByte and reverse
+- get rid of ninja warnings
- test LSP on windows
- what status does cmd return if the program is not found? (lsp.c:301)
- switch to CreateProcessW
diff --git a/os-win.c b/os-win.c
index b3c931a..10d121f 100644
--- a/os-win.c
+++ b/os-win.c
@@ -110,6 +110,12 @@ int os_get_cwd(char *buf, size_t buflen) {
return 1;
}
+int os_rename_overwrite(const char *oldname, const char *newname) {
+ wchar_t wide_oldname[4100];
+ wchar_t wide_newname[4100];
+
+}
+
struct timespec time_last_modified(const char *path) {
struct timespec ts = {0};
FILETIME write_time = {0};
diff --git a/os.h b/os.h
index d2920db..a670a6b 100644
--- a/os.h
+++ b/os.h
@@ -43,6 +43,11 @@ int fs_mkdir(const char *path);
// 0 if buf is too short to hold the cwd
// -1 if we can't get the cwd for whatever reason.
int os_get_cwd(char *buf, size_t buflen);
+// Unlike ISO C rename() function, this will overwrite `newname` if it exists.
+// Returns:
+// >= 0 if successful
+// < 0 on error
+int os_rename_overwrite(const char *oldname, const char *newname);
struct timespec time_last_modified(const char *filename);
struct timespec time_get(void);
// sleep for a certain number of nanoseconds