getcwd

How do Perl Cwd::cwd and Cwd::getcwd functions differ?

喜欢而已 提交于 2019-12-10 02:15:48
问题 The question What is the difference between Cwd::cwd and Cwd::getcwd in Perl, generally, without regard to any specific platform? Why does Perl have both? What is the intended use, which one should I use in which scenarios? (Example use cases will be appreciated.) Does it matter? (Assuming I don’t mix them.) Does choice of either one affect portability in any way? Which one is more commonly used in modules? Even if I interpret the manual is saying that except for corner cases cwd is `pwd` and

Why does getcwd() returns / in __destruct()?

对着背影说爱祢 提交于 2019-12-05 10:20:23
I have just noticed that getcwd() return "/" if called within __destruct() magic function, while in any other method it returns the expected path. Do you have an explanation for this? It's a SAPI behaivor "Destructors called during the script shutdown have HTTP headers already sent. The working directory in the script shutdown phase can be different with some SAPIs (e.g. Apache)." From http://php.net/manual/en/language.oop5.decon.php But as mentioned in other answers there are plenty ways to get the current relative path. If you changed it during runtime make sure to note somewhere inside the

How do Perl Cwd::cwd and Cwd::getcwd functions differ?

旧街凉风 提交于 2019-12-05 01:15:40
The question What is the difference between Cwd::cwd and Cwd::getcwd in Perl, generally, without regard to any specific platform? Why does Perl have both? What is the intended use, which one should I use in which scenarios? (Example use cases will be appreciated.) Does it matter? (Assuming I don’t mix them.) Does choice of either one affect portability in any way? Which one is more commonly used in modules? Even if I interpret the manual is saying that except for corner cases cwd is `pwd` and getcwd just calls getcwd from unistd.h , what is the actual difference? This works only on POSIX

shell init issue when click tab, what's wrong with getcwd?

不问归期 提交于 2019-12-03 02:29:09
问题 once i click Tab on bash, the error message will appear, what's wrong? symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success symlink

shell init issue when click tab, what's wrong with getcwd?

自作多情 提交于 2019-12-02 16:01:53
once i click Tab on bash, the error message will appear, what's wrong? symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: No such file or

get current working directory in Lua

狂风中的少年 提交于 2019-11-30 17:23:56
What's the Lua to get the current working directory on Windows XP SP3 (or to get the directory of the currently-running Lua file)? I prefer not to use LuaFileSystem . I can't use os.execute("cd") because os.execute always starts from my home directory (and thus always yields C:\Documents and Settings\username ). Lua by default doesn't have a "native" way of supporting the concept of "current directory", or, in fact, the concept of "directory". The proper way to get the current directory is using a library that provides folder support. There are several - I recommend luafilesystem . Once it is

PHP: How to set current working directory to be same as directory executing the script

狂风中的少年 提交于 2019-11-27 22:48:39
I'm in the process of transferring my website from one server to another. I have some php scripts that use the is_readable function which uses the current working directory. On the old server, when I call getcwd(), it outputs the folder in which the script is being executed. On the new server it outputs the root directory '/'. I would like to know how I can configure PHP to use the current folder instead of '/'. I don't want to have to change any PHP code that already works on the old server. I can configure the new server, but don't know what settings to change. I'm using apache2, if that

What is a cross-platform way to get the current directory?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 22:06:12
I need a cross-platform way to get the current working directory (yes, getcwd does what I want). I thought this might do the trick: #ifdef _WIN32 #include <direct.h> #define getcwd _getcwd // stupid MSFT "deprecation" warning #elif #include <unistd.h> #endif #include <string> #include <iostream> using namespace std; int main() { string s_cwd(getcwd(NULL,0)); cout << "CWD is: " << s_cwd << endl; } I got this reading: _getcwd at MSDN getcwd at Kernel.org getcwd at Apple.com There should be no memory leaks, and it should work on a Mac as well, correct? UPDATE: I fear something is still wrong here

Is there a C++ equivalent to getcwd?

梦想的初衷 提交于 2019-11-27 02:30:24
问题 I see C's getcwd via: man 3 cwd I suspect C++ has a similar one, that could return me a std::string . If so, what is it called, and where can I find it's documentation? Thanks! 回答1: Ok, I'm answering even though you already have accepted an answer. An even better way than to wrap the getcwd call would be to use boost::filesystem, where you get a path object from the current_path() function. The Boost filesystem library allows you to do lots of other useful stuff that you would otherwise need

PHP: How to set current working directory to be same as directory executing the script

蹲街弑〆低调 提交于 2019-11-26 21:09:49
问题 I'm in the process of transferring my website from one server to another. I have some php scripts that use the is_readable function which uses the current working directory. On the old server, when I call getcwd(), it outputs the folder in which the script is being executed. On the new server it outputs the root directory '/'. I would like to know how I can configure PHP to use the current folder instead of '/'. I don't want to have to change any PHP code that already works on the old server.