diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-06-20 16:47:54 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-06-20 16:47:54 +0000 |
| commit | 8d4f29d3024c328c892b37f7b7db27fbde022e51 (patch) | |
| tree | 9fecf82f3b70fbb954dfdea8cf9ab4291e2ecf62 /src/File.cc | |
| parent | 3636345a25646c407b07af7679f37a2f8708e1e9 (diff) | |
2009-06-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
The default value of --dir option is the absolute path to the
current directory. If getcwd() is failed, then it is ".", which is
the same value with old implementation. This change is necessary
because after daemon() call, the current working directory is
changed to /.
* src/File.cc
* src/File.h
* src/OptionHandlerFactory.cc
* src/option_processing.cc
Diffstat (limited to 'src/File.cc')
| -rw-r--r-- | src/File.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/File.cc b/src/File.cc index 705059da..5550213e 100644 --- a/src/File.cc +++ b/src/File.cc @@ -37,6 +37,7 @@ #include <stdlib.h> #include <sys/types.h> #include <utime.h> +#include <unistd.h> #include <deque> #include <cstring> @@ -44,6 +45,7 @@ #include "Util.h" #include "A2STR.h" +#include "array_fun.h" namespace aria2 { @@ -201,4 +203,20 @@ Time File::getModifiedTime() return Time(fstat.st_mtime); } +std::string File::getCurrentDir() +{ + size_t buflen = 256; + while(buflen <= 2048) { + array_ptr<char> buf(new char[buflen]); + if(getcwd(buf, buflen)) { + return std::string(buf); + } else if(errno == ERANGE) { + buflen *= 2; + } else { + break; + } + } + return A2STR::DOT_C; +} + } // namespace aria2 |
