aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c/data.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/c/data.h b/c/data.h
index 4fbf3e4..7ca5e6c 100644
--- a/c/data.h
+++ b/c/data.h
@@ -93,11 +93,29 @@ struct FileView
memcpy(fv+i, &t, sizeof(T));
}
- return { filename, c };
+ return {filename, c};
}
FileView(FileView<T>&) = delete;
- FileView(FileView<T>&& fv) = delete;
+ FileView<T>& operator =(const FileView<unsigned char>&) = delete;
+
+ FileView(FileView<T>&& other)
+ {
+ hf = other.hf;
+ hm = other.hf;
+ view = other.view;
+ c = other.c;
+ other.view = nullptr;
+ }
+ FileView<T>& operator =(FileView<unsigned char>&& other)
+ {
+ hf = other.hf;
+ hm = other.hf;
+ view = other.view;
+ c = other.c;
+ other.view = nullptr;
+ return *this;
+ }
FileView(const wchar_t* filename, size_t c) : c(c)
{
@@ -131,10 +149,12 @@ struct FileView
~FileView()
{
- FlushViewOfFile(view, 0);
- UnmapViewOfFile(view);
- CloseHandle(hm);
- CloseHandle(hf);
+ if (view) {
+ FlushViewOfFile(view, 0);
+ UnmapViewOfFile(view);
+ CloseHandle(hm);
+ CloseHandle(hf);
+ }
}
/* Access element by index, performing bounds check and, if