Menu

#3 Can't use relative paths in open file

Todo
open
Nick
3
2002-10-22
2002-10-22
Nick
No

The following doesn't work.
struct file_handler *fh;
struct dir_handler *dh;
char *str;
struct file *file;
struct dir *dir,*subdir;

dh = find_dir_handler("ufs);
fh = find_file_handler("ufs);

dir = dh->open(NULL,"/home/zaf/"); /* Opens /home/zaf
as the root dir */
subdir = dh->open(dir,"test"); /* Opens /home/zaf/test */
file = fh->open(subdir,"../file.txt",file_read_only);
/* Tries to open /home/zaf/test/file.txt instead of
/home/zaf/file.txt */

Discussion


Log in to post a comment.