00001
00002
00003
00004 #include <string.h>
00005 #include "machine.h"
00006 #ifdef _MSC_VER
00007 #include <windows.h>
00008 #else
00009 #include <unistd.h>
00010 #define GETCWD(x,y) getcwd(x,y)
00011 #endif
00012 #include "sciprint.h"
00013 #include "scicurdir.h"
00014 #define FSIZE 1024
00015 static char cur_dir[FSIZE];
00016
00017 int C2F(scichdir)(char *path,int *err)
00018 {
00019 *err=0;
00020 if (path == (char*) NULL)
00021 {
00022 *cur_dir = '\0';
00023 return (0);
00024 }
00025 #ifndef _MSC_VER
00026 if (chdir(path) == -1)
00027 {
00028 sciprint("Can't go to directory %s \r\n", path);
00029 *err=1;
00030 }
00031 #else
00032 if (SetCurrentDirectory(path) == 0)
00033 {
00034 sciprint("Can't go to directory %s \r\n", path);
00035 *err=1;
00036 }
00037 #endif
00038 return 0;
00039 }
00040
00041 int C2F(scigetcwd)(char **path,int *lpath,int *err)
00042 {
00043 #ifndef _MSC_VER
00044 if (GETCWD(cur_dir, FSIZE) == (char*) 0)
00045 #else
00046 if ( GetCurrentDirectory(FSIZE,cur_dir) == 0 )
00047 #endif
00048 {
00049
00050 sciprint("Can't get current directory\r\n");
00051 *cur_dir = '\0';
00052 *lpath=0;
00053 *err=1;
00054 }
00055 else
00056 {
00057 *path= cur_dir;
00058 *lpath=strlen(cur_dir);
00059 *err=0;
00060 }
00061 return 0;
00062 }
00063