diff common/util.h @ 983:427e2e18b8c8

Move Shell functions into util Due to a bug in mingw only one c file may include shlobj.h as there is an unguarded inline definition in there leading to multiple definition errors. Thus the get_program_data get_program_files utility functions.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 29 Aug 2014 17:11:35 +0200
parents 216a65d7fc4b
children 1c1964c27b39 6684e5012b7a
line wrap: on
line diff
--- a/common/util.h	Fri Aug 29 16:08:50 2014 +0200
+++ b/common/util.h	Fri Aug 29 17:11:35 2014 +0200
@@ -100,6 +100,42 @@
  */
 char * read_registry_string (const HKEY root, const wchar_t *key,
                              const wchar_t *name);
+
+/**@brief Get the utf-8 encoded path to the program files folder.
+ *
+ * Uses SHGetKnownFolderPath to look up the ProgramFiles folder.
+ * @returns a newly allocated string containing the value or NULL on
+ * error.
+ */
+char * get_program_files_folder ();
+
+/**@brief Get the path to the program data folder.
+ *
+ * Uses SHGetKnownFolderPath to look up the ProgramData folder.
+ * The return value should be freed with CoTaskMemFree
+ * @returns a reference containing the value or NULL on error.
+ */
+wchar_t * get_program_data_folder ();
+
+/**@brief Create a directory with restricted access rights
+  *
+  * This creates a security attributes structure that restricts
+  * write access to the Administrators group but allows everyone to read files
+  * in that directory.
+  * Basically a very complicated version of mkdir path -m 644
+  *
+  * If the directory exists the permissions of that directory are checked if
+  * they are acceptable and true or false is returned accordingly.
+  *
+  * Code based on msdn example:
+  * http://msdn.microsoft.com/en-us/library/windows/desktop/aa446595%28v=vs.85%29.aspx
+  *
+  * @param[in] path Path of the directory to create
+  *
+  * @returns true on success of if the directory exists, false on error
+  */
+bool create_restricted_directory (LPWSTR path);
+
 #endif
 
 #ifdef __cplusplus

http://wald.intevation.org/projects/trustbridge/