mirror of
https://github.com/storytold/cadcraft.git
synced 2026-11-21 20:40:02 +00:00
Stack r1: #2745: the portable write probe writes a byte; the README names the profile's app.ron to copy
This commit is contained in:
@@ -200,7 +200,9 @@ settings are not automatically copied into the portable directory.
|
||||
|
||||
Before switching an existing Windows installation to portable mode, close CADCraft,
|
||||
back up `%APPDATA%\CADCraft`, and copy the settings you want to retain into
|
||||
`CADCraftData`. Include the `autosave` folder if you need to recover unsaved drawings.
|
||||
`CADCraftData`. Include the `autosave` folder if you need to recover unsaved drawings. The
|
||||
preferences and window state are kept apart, in `%APPDATA%\ai.storyteller.cadcraft\data\app.ron`:
|
||||
copy that file to `CADCraftData\app.ron` to keep them.
|
||||
Updating a portable ZIP, including through the updater, can restore `portable.txt`;
|
||||
set `CADCRAFT_CONFIG_DIR` to your existing profile folder to keep using it across updates.
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Windows portable ZIP settings, selected by a marker beside the executable.
|
||||
|
||||
use std::io::Write as _;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// A marker must be a file. Prove the data folder is writable before selecting it.
|
||||
@@ -10,9 +11,13 @@ pub(crate) fn directory_in(exe_dir: &Path) -> std::io::Result<Option<PathBuf>> {
|
||||
let data = exe_dir.join("CADCraftData");
|
||||
std::fs::create_dir_all(&data)?;
|
||||
let probe = data.join(format!(".portable-write-test-{}", std::process::id()));
|
||||
let file = std::fs::OpenOptions::new().write(true).create_new(true).open(&probe)?;
|
||||
// A byte, not just an empty file: a full drive can still make the file and refuse its data.
|
||||
let mut file = std::fs::OpenOptions::new().write(true).create_new(true).open(&probe)?;
|
||||
let written = file.write_all(&[0]).and_then(|()| file.sync_all());
|
||||
drop(file);
|
||||
std::fs::remove_file(probe)?;
|
||||
let removed = std::fs::remove_file(&probe);
|
||||
written?;
|
||||
removed?;
|
||||
Ok(Some(data))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user