メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

lo-sysdep.cc

解説を見る。
00001 /*
00002 
00003 Copyright (C) 1996, 1997 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 2, or (at your option) any
00010 later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <iostream>
00028 #include <string>
00029 
00030 #ifdef HAVE_UNISTD_H
00031 #ifdef HAVE_SYS_TYPES_H
00032 #include <sys/types.h>
00033 #endif
00034 #include <unistd.h>
00035 #endif
00036 
00037 #include "lo-error.h"
00038 #include "pathlen.h"
00039 
00040 std::string
00041 octave_getcwd (void)
00042 {
00043   std::string retval;
00044 
00045   char buf[MAXPATHLEN];
00046 
00047   char *tmp = 0;
00048 
00049 #if defined (__EMX__)
00050   tmp = _getcwd2 (buf, MAXPATHLEN);
00051 #elif defined (HAVE_GETCWD)
00052   tmp = getcwd (buf, MAXPATHLEN);
00053 #elif defined (HAVE_GETWD)
00054   tmp = getwd (buf);
00055 #endif
00056 
00057   if (tmp)
00058     retval = tmp;
00059   else
00060     (*current_liboctave_error_handler) ("unable to find current directory");
00061 
00062   return retval;
00063 }
00064 
00065 int
00066 octave_chdir (const std::string& path)
00067 {
00068 #if defined (__EMX__)
00069   int retval = -1;
00070 
00071   char *tmp_path = strsave (path.c_str ());
00072 
00073   if (path.length () == 2 && path[1] == ':')
00074     {
00075       char *upper_case_dir_name = strupr (tmp_path);
00076       _chdrive (upper_case_dir_name[0]);
00077       if (_getdrive () == upper_case_dir_name[0])
00078         retval = _chdir2 ("/");
00079     }
00080   else
00081     retval = _chdir2 (tmp_path);
00082 
00083   delete [] tmp_path;
00084 
00085   return retval;
00086 #else
00087   return chdir (path.c_str ());
00088 #endif
00089 }
00090 
00091 /*
00092 ;;; Local Variables: ***
00093 ;;; mode: C++ ***
00094 ;;; End: ***
00095 */

Wed Dec 29 11:51:42 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送