Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confusion with directory documentation #47

Open
x37v opened this issue Feb 1, 2022 · 3 comments
Open

confusion with directory documentation #47

x37v opened this issue Feb 1, 2022 · 3 comments

Comments

@x37v
Copy link
Contributor

x37v commented Feb 1, 2022

A couple notes/questions:

  1. open_root_dir and open_dir both indicate: Open a directory. You can then read the directory entries in a random order using get_directory_entry. But get_directory_entry doesn't exist in the code AFAIK. I see find_directory_entry and iterate_dir so I assume this must just be left over cruft?

  2. open_root_dir and open_dir return a Directory, the docs for close_dir indicate:
    Close a directory. You cannot perform operations on an open directory and so must close it if you want to do something with it. but close_dir consumes a directory so how do you use it after its closed? For instance, how would you supply a directory to open_file_in_dir ?

@x37v
Copy link
Contributor Author

x37v commented Feb 1, 2022

looking at this example.. i'm guessing the close_dir documentation is wrong?

let root_dir = controller.open_root_dir(&volume).unwrap();
println!("\tListing root directory:");
controller
.iterate_dir(&volume, &root_dir, |x| {
println!("\t\tFound: {:?}", x);
})
.unwrap();
println!("\tFinding {}...", FILE_TO_PRINT);
println!(
"\tFound {}?: {:?}",
FILE_TO_PRINT,
controller.find_directory_entry(&volume, &root_dir, FILE_TO_PRINT)
);
let mut f = controller
.open_file_in_dir(&mut volume, &root_dir, FILE_TO_PRINT, Mode::ReadOnly)
.unwrap();

@x37v
Copy link
Contributor Author

x37v commented Feb 21, 2022

we resolved 1 with that PR but 2 .. the documentation about close_dir is still confusing

@thejpster
Copy link
Member

I think 2. means you can’t create a file in a directory when the directory is open? Because then you could get iterator invalidation if the entries moved around. But I agree the wording is awful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants