Relative paths are implicitly relative to the current directory. If you want it to be relative to something else, use joinpath(dir, path) to get a path relative to dir instead. Changing directories here is kind of heavy handed.
On Saturday, October 24, 2015, <[email protected]> wrote: > Works great, the function mtime is exactly what I needed. > One more syntax shortening: mtime(f) works as good as stat(f).mtime. > That's the function I needed. > > A last remark, if I want to look for the last modified file of a directory > different from the working directory, this function fails: > > function get_last_modified(path) > last_modified = first(sort(map(f -> (realpath(f), > Dates.unix2datetime(mtime(f))), readdir(path)), by = last, rev = true))[1] > return last_modified > end > > because I guess that realpath tries to concatenate the working directory > with the name of the file. So the workaround I'm using, not very beautiful > but it at least works: > > function get_last_modified(path) > wd = pwd() > cd(path) > last_modified = first(sort(map(f -> (realpath(f), > Dates.unix2datetime(mtime(f))), readdir(path)), by = last, rev = true))[1] > cd(wd) > return last_modified > end > >
