#include <unistd.h>\r
//+---int chdir(const char *path); カレントディレクトリの変更\r
//+---char *getcwd(char *buf, size_t size); 現在のカレントディレクトリを取得\r
+#define CHNLIB_PATH_SEPARATOR '/'\r
#endif\r
\r
\r
#define getcwd(a,b) _getcwd(a,b)\r
//+---int _chdir(const char *dirname);\r
//+---char *_getcwd(char *buffer, int maxlen);\r
+#define CHNLIB_PATH_SEPARATOR '\'\r
#endif\r
\r
\r
\r
void CHNLIB_Environment_SetCurrentWorkingDirectory(const char apppath[])\r
{\r
+ //カレントディレクトリを実行ファイルのディレクトリに変更\r
char path[FILENAME_MAX];\r
int i, last;\r
- \r
- //カレントディレクトリを実行ファイルのディレクトリに変更\r
+\r
snprintf(path, sizeof(path), "%s", apppath);\r
last = 0;\r
for(i = 0; i < FILENAME_MAX; i++){\r
\r
return;\r
}\r
+\r
+const char *CHNLIB_Environment_GetFilenameFromPath(const char path[])\r
+{\r
+ //path文字列から、ファイル名を指し示す文字列の先頭部分のポインタを返す。\r
+ int i, p;\r
+ \r
+ if(path == NULL){\r
+ return NULL;\r
+ }\r
+ \r
+ p = 0;\r
+ for(i = 0; path[i] != '\0'; i++){\r
+ if(path[i] == CHNLIB_PATH_SEPARATOR){\r
+ p = i + 1;\r
+ }\r
+ }\r
+ \r
+ return &path[p];\r
+}\r