diff options
author | Marius Kintel <marius@kintel.net> | 2013-04-27 04:55:15 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-04-27 04:55:15 (GMT) |
commit | 6b3daa748543f13cc7cf8eff1c9efeebd6dc3a14 (patch) | |
tree | 8869b03872b42ce1ffb1755958d05925f9f0bcb4 /src/dxfdim.cc | |
parent | f0ee85e17d474ab9119f82ee6f802d4634743b12 (diff) | |
parent | 5f10c9f9c0a9805567ea8f9b560c6e0b50126119 (diff) |
Merge pull request #326 from openscad/issue217
Issue217
Diffstat (limited to 'src/dxfdim.cc')
-rw-r--r-- | src/dxfdim.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 1ed37fa..53bc480 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -49,6 +49,9 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnam double yorigin = 0; double scale = 1; + // FIXME: We don't lookup the file relative to where this function was instantiated + // since the path is only available for ModuleInstantiations, not function expressions. + // See isse #217 for (size_t i = 0; i < argnames.size() && i < args.size(); i++) { if (argnames[i] == "file") filename = ctx->getAbsolutePath(args[i].toString()); @@ -63,9 +66,16 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnam } std::stringstream keystream; + fs::path filepath(filename); + uintmax_t filesize = -1; + time_t lastwritetime = -1; + if (fs::exists(filepath) && fs::is_regular_file(filepath)) { + filesize = fs::file_size(filepath); + lastwritetime = fs::last_write_time(filepath); + } keystream << filename << "|" << layername << "|" << name << "|" << xorigin - << "|" << yorigin <<"|" << scale << "|" << fs::last_write_time(filename) - << "|" << fs::file_size(filename); + << "|" << yorigin <<"|" << scale << "|" << lastwritetime + << "|" << filesize; std::string key = keystream.str(); if (dxf_dim_cache.find(key) != dxf_dim_cache.end()) return dxf_dim_cache.find(key)->second; @@ -133,6 +143,9 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector<std::string> &argn double yorigin = 0; double scale = 1; + // FIXME: We don't lookup the file relative to where this function was instantiated + // since the path is only available for ModuleInstantiations, not function expressions. + // See isse #217 for (size_t i = 0; i < argnames.size() && i < args.size(); i++) { if (argnames[i] == "file") filename = ctx->getAbsolutePath(args[i].toString()); |