Commit Graph

8 Commits

Author SHA1 Message Date
Andrew Ayer
3799a23aa7 Add missing argument when throwing System_error 2014-09-21 12:00:31 -07:00
Andrew Ayer
690dba2f14 Add multi-platform remove_file helper
And use it for deleting internal keys
2014-09-21 12:00:31 -07:00
Andrew Ayer
47e810d592 Write and use create_protected_file() helper
Instead of using umask to ensure sensitive files are created with
restrictive permissions, git-crypt now does:

	create_protected_file(filename);
	std::ofstream out(filename);
	// ...

create_protected_file can have different Unix and Windows implementations.
create_protected_file should be easier to implement on Windows than a
umask equivalent, and this pattern keeps the amount of platform-specific
code to a minimum and avoids #ifdefs.
2014-08-02 21:18:28 -07:00
Andrew Ayer
f03d972937 Add get_directory_contents utility function 2014-07-02 22:10:09 -07:00
Andrew Ayer
e6bb66b93a Add touch_file() utility function 2014-06-26 23:03:30 -07:00
Cyril Cleaud
df2b472cd9 Add umask and rename compatibility wrappers for Windows
umask() doesn't exist on Windows and is thus a no-op.

rename() only works if the destination doesn't already exist,
so we must unlink before renaming.
2014-06-26 23:03:30 -07:00
Andrew Ayer
6e43b2a1cd New exec_command() that takes command as array instead of string
This abstracts away the details of argument quoting, which differs
between Unix and Windows.

Also replace all uses of the system() library call with exec_command().
Although system() exists on Windows, it executes the command via cmd.exe,
which has ridiculous escaping rules.
2014-06-12 21:23:04 -07:00
Andrew Ayer
0774ed018c Lay groundwork for Windows support
Move Unix-specific code to util-unix.cpp, and place Windows equivalents
in util-win32.cpp.  Most of the Windows functions are just stubs at
the moment, and we need a build system that works on Windows.
2014-06-12 21:23:02 -07:00