16 #include <boost/bind.hpp>
17 #include <boost/filesystem/path.hpp>
18 #include <boost/filesystem/operations.hpp>
21 using namespace kome::core;
26 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
27 #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
32 #define APP_NAME "Mass++"
33 #define REG_NAME "Mass++2"
34 #define MSPP_VERSION "2.7.5"
36 #define TO_STR( s ) TO_STR_( s )
37 #define TO_STR_( s ) #s
60 #if defined(_WIN64) || defined(__amd64__)
64 #endif // _WIN64 || __amd64__
99 #ifdef MSPP_INSTALL_DIR
104 #endif // MSPP_INSTALL_DIR
114 const char* envariables[] = {
115 "TMP",
"TEMP",
"tmp",
"temp"
117 unsigned int num =
sizeof( envariables ) /
sizeof(
const char* );
120 for(
unsigned int i = 0; i < num && tmpDir.empty(); i++ ) {
126 if( pos != tmpDir.npos ) {
127 tmpDir = tmpDir.substr( 0, pos );
131 if( tmpDir.empty() ) {
155 boost::filesystem::path p(
m_tmpDir.c_str(), boost::filesystem::native );
156 boost::filesystem::directory_iterator end;
158 for( boost::filesystem::directory_iterator it( p ); it != end; it++ ) {
159 boost::filesystem::path child = boost::filesystem::absolute( *it );
161 std::string fileName =
getfilename( child.string().c_str() );
162 int pid =
toint( fileName.c_str(), 16,
m_pid );
184 std::string pidStr = FMT(
"%04x",
m_pid );
200 std::string fileName;
201 std::string d =
NVL( dir,
"" );
205 if( tmpDir.empty() ) {
214 d =
getpath( tmpDir.c_str(), d.c_str() );
225 localtime_s( &date, &now );
227 date = *( localtime( &now ) );
232 while( path.empty() && count >= 0 ) {
235 "%s%02d%02d%02d%04x%s",
243 for(
unsigned int i = 0; i < fileName.length(); i++ ) {
244 char c = fileName[ i ];
245 if( c ==
'/' || c ==
'\\' || c ==
':' || c ==
'?'
246 || c ==
'>' || c ==
'<' || c ==
'|' || c ==
' '
247 || c ==
'\r' || c ==
'\t' || c ==
'\n' || c ==
',' ) {
261 LOG_TRACE( FMT(
"Temporary File [%s]", path.c_str() ) );
std::string getfilename(const char *path)
get file name
std::string getenvariable(const char *name)
get environment variable
static MsppManager & getInstance()
gets MsppManager object (This is the only object.)
std::vector< std::string > getPluginDir()
get mspp plugin dir
bool isabsolutepath(const char *file)
judges whether the specified file path is absolute file path or not.
bool removedirs(const char *path)
remove directories
const char * getConfDir()
gets config directory
std::string getmoduledir()
gets module file directory
const char * getRegName()
gets the registory name
IniFile * getIniFile()
gets ini file
void setInitializedMATLAB(void)
sets initialized flag value
bool makedirs(const char *path)
make directories
const char * getPlatformName()
gets the platform name
IniFile * getParameters()
gets parameters
int toint(const char *s, const int radix, const int dfval)
convert string into integer
bool fileexists(const char *path)
judge whether file exists
std::string getabsolutepath(const char *dir, const char *file)
get absolute path
void resetInitializedMATLAB(void)
resets initialized flag value
void setParameters(IniFile *params)
sets parameters file
unsigned int stringtoken(const char *s, const char *delim, std::vector< std::string > &tokens)
get tokens from string
const char * getTmpDir()
gets temporary file directory name
#define NVL(checkVal, replaceVal)
void setIniFile(IniFile *ini)
sets ini file
bool makedirectory(const char *path)
creates directory
implements of MsppManager class
void deleteTmpFiles()
deletes temporary files
const char * getVersion()
gets Mass++ version
bool m_bInitializedMATLAB
const char * getMsppDir()
gets Mass++ directory
const char * getAppName()
gets the application name
bool processexists(const unsigned int pid)
judges whether specified process is exists or not.
std::string getplugindir()
gets mspp plugin paths
unsigned int getprocessid()
gets procsess ID
ini file management class
unsigned int getPid()
gets the process ID
void setPath()
sets file path
std::string getTmpFileName(const char *prefix, const char *suffix, const char *dir=NULL)
gets temporary file name
std::string gethomedir()
gets current user's home directory
virtual ~MsppManager()
destructor
void setPluginDir()
set mspp plugin dir
std::vector< std::string > m_pluginPaths
bool isInitializedMATLAB(void)
gets MATLAB's initialized flag value
std::string getpath(const char *dir, const char *file)
get file path