Skip to content
Browse files

Merge pull request #1762 from RussWhitehead/queryTemp

FIX: add new jfile "getTempfilePath" function

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
  • Loading branch information...
2 parents 2d3ea6a + 223274c commit 185b836f68dc7ee3aba4fd0322171071aea83640 @ghalliday ghalliday committed Mar 6, 2012
Showing with 26 additions and 0 deletions.
  1. +25 −0 system/jlib/jutil.cpp
  2. +1 −0 system/jlib/jutil.hpp
View
25 system/jlib/jutil.cpp
@@ -2554,6 +2554,31 @@ int parseCommandLine(const char * cmdline, MemoryBuffer &mb, const char** &argvo
return 0;
}
+jlib_decl StringBuffer &getTempFilePath(StringBuffer & target, const char * component, IPropertyTree * pTree)
+{
+ StringBuffer dir;
+ if (pTree)
+ getConfigurationDirectory(pTree->queryPropTree("Directories"),"temp",component,pTree->queryProp("@name"),dir);
+ if (!dir.length())
+ {
+#ifdef _WIN32
+ char path[_MAX_PATH+1];
+ if(GetTempPath(sizeof(path),path))
+ dir.append(path).append("HPCCSystems\\hpcc-data");
+ else
+ dir.append("c:\\HPCCSystems\\hpcc-data\\temp");
+#else
+ dir.append(getenv("TMPDIR"));
+ if (!dir.length())
+ dir.append("/var/lib");
+ dir.append("/HPCCSystems/hpcc-data/temp");
+#endif
+ }
+ dir.append(PATHSEPCHAR).append(component);
+ recursiveCreateDirectory(dir.str());
+ return target.set(dir);
+}
+
//#define TESTURL
#ifdef TESTURL
View
1 system/jlib/jutil.hpp
@@ -269,6 +269,7 @@ extern jlib_decl int parseCommandLine(const char * cmdline, MemoryBuffer &mb, co
extern jlib_decl bool safe_ecvt(size_t len, char * buffer, double value, int numDigits, int * decimal, int * sign);
extern jlib_decl bool safe_fcvt(size_t len, char * buffer, double value, int numPlaces, int * decimal, int * sign);
+extern jlib_decl StringBuffer &getTempFilePath(StringBuffer & target, const char * component, IPropertyTree * pTree);
#endif

0 comments on commit 185b836

Please sign in to comment.
Something went wrong with that request. Please try again.