Add config writing capability #99
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/artiq-zynq#99
Loading…
Reference in New Issue
No description provided.
Delete Branch "(deleted):master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#63
The new function write_str has been tested. It works with both long (more than 100 characters) and short strings.
This needs to be used in the management interface so that
artiq_coremgmt
can write config keys across the network.@ -106,0 +109,4 @@
let root_dir = fs.root_dir();
let mut file;
let isascii_and_short = data.is_ascii() & (data.len() <= 100);
A better variable name would be
use_config_txt
.@ -106,0 +107,4 @@
pub fn write_str<'b>(&mut self, key: &str, data: &str) -> Result<'b, ()>{
if let Some(fs) = &self.fs {
let root_dir = fs.root_dir();
let mut file;
AFAICT this does not need a forward declaration.
You can just do
let mut file = match...
below. Themut
is perhaps not needed either.If mut is not used, I get "cannot borrow as mutable" when calling truncate and write_all
@ -106,0 +131,4 @@
if isascii_and_short {
match root_dir.remove(config_key_bin) {
Ok(_) => {},
Err(_) => {}
You want to report errors that are not "the file doesn't exist".
@ -106,0 +125,4 @@
file.truncate()?;
file.write_all(&[key,"="].concat().as_bytes())?;
file.write_all(data.as_bytes())?;
Why not a single
file.write_all(&[key, "=", data].concat().as_bytes())?
(or similar) ?Also, won't that erase all the other keys from
config.txt
?@ -106,0 +130,4 @@
if use_config_txt {
match root_dir.remove(config_key_bin) {
Ok(_) => {},
Err(e) => match e.kind() {
You could simply add a
Err(ErrorKind::NotFound)
branch to the mainmatch
statement...Pull request closed