What are the restrictions on file paths when opening a file with fopen
I write rule generate-entity to generate a java entity:
generate-entity: (selected, position, ast, path, project-path) -> None() with filename := <guarantee-extension(|"java")><concat-strings>["generated/src/",<remove-extension><base-filename>path]; result := <to-entity>selected; handle := <fopen> (filename, "w"); <fputs> (result, handle); fclose
I want to generate the file in path “generate/src/entity”,but there are errors when executing,while I cut the path to “generate/src”,it works!Is there any limits about the filepath?
Asked by ZJG on 19 March 2013 at 07:10
2 Answers
Please use a specific header for your question, otherwise your question will not be helpful for other people.
Q: What are the restrictions on file paths when opening a file with
Answered by Guido Wachsmuth on 19 March 2013 at 07:26fopen
?
A: All directories in the path must exist.
You can create the path with the
Answered by Gabriël Konat on 19 March 2013 at 08:58mkdir
strategy. It fails if the path already exists, so you can put a try around it:try(mkdir)