Skip to content

Commit

Permalink
Store shared data/config in ProgramData (andybarron#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
agersant authored and andybarron committed Feb 4, 2017
1 parent a8d6f8b commit 7fef8f8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/imp/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ pub const USE_AUTHOR: bool = true;

pub fn get_app_dir(t: AppDataType) -> Result<PathBuf, AppDirsError> {
let folder_id = match t {
UserConfig | UserData | SharedConfig | SharedData => &FOLDERID_RoamingAppData,
UserConfig | UserData => &FOLDERID_RoamingAppData,
SharedConfig | SharedData => &FOLDERID_ProgramData,
UserCache => &FOLDERID_LocalAppData,
};
get_folder_path(folder_id).map(|os_str| os_str.into())
Expand All @@ -55,6 +56,15 @@ static FOLDERID_LocalAppData: GUID = GUID {
Data4: [0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91],
};

/// https://msdn.microsoft.com/en-us/library/dd378457.aspx#FOLDERID_ProgramData
#[allow(non_upper_case_globals)]
static FOLDERID_ProgramData: GUID = GUID {
Data1: 0x62AB5D82,
Data2: 0xFDC1,
Data3: 0x4DC3,
Data4: [0xA9, 0xDD, 0x07, 0x0D, 0x1D, 0x49, 0x5D, 0x97],
};

/// Wrapper around `winapi::PWSTR` to automatically free the string pointer.
/// This ensures the memory is freed when `get_folder_path` scope is left,
/// regardless of whether the call succeeded or failed/panicked.
Expand Down

0 comments on commit 7fef8f8

Please sign in to comment.