Questions tagged [getcwd]

The getcwd() function retrieves the current working directory pathname on POSIX compliant machines.

The function getcwd() is available on Unix machines to copy the current working directory (as an absolute pathname) to a supplied buffer of an array of characters of a given length. It is specified in POSIX.1-2001 to have the following signature:

char *getcwd(char *buffer, size_t size);
88 questions
0
votes
1 answer

python's os.getcwd() randomly stops working

I run a python 2.7 program with tensorflow on my ubuntu 16.04 machine. At some point (it randomly changes when that happens), the program crashes because os.getcwdu() fails. I then run python in the same terminal session, try to run import os…
0
votes
1 answer

Why does system() complain that cwd is not known?

I am using system() to run some Unix commands from my application with code like the following: std::stringstream command; command << "rm -rf /some/directory"; int rmResult = system(command.str().c_str()); if (rmResult != 0) { clog << "Error:…
WilliamKF
  • 36,283
  • 61
  • 170
  • 271
0
votes
2 answers

Why getcwd fails with errno ENOENT

I'm using the getcwd function to retrieve the current working directory of my application. In some cases it fails and errno is ENOENT. I call getcwd from different threads, but serially and sometimes I face with ENOENT, but I don't know why. The…
rboc
  • 165
  • 1
  • 7
0
votes
1 answer

Print getcwd path

My instructions are pretty clear, but I'm doing it wrong, can you help correct my error? Instructions: else if (“pwd”) declare a char variable array of size MAX_PATH_LENGTH to hold the path do a getcwd print the path my code: }else…
TeSa
  • 37
  • 7
0
votes
2 answers

python3, directory is not correct when import a module in sub-folder

I have a main folder called 'test', the inner structure is: # folders and files in the main folder 'test' Desktop\test\use_try.py Desktop\test\cond\__init__.py # empty file. Desktop\test\cond\tryme.py Desktop\test\db\ Now in the file tryme.py. I…
aura
  • 461
  • 5
  • 14
0
votes
1 answer

Perl - get abs path to module from other directory in main script

I created a simple perl script which is splited into 2 files - main.pl and content.pm The main script is placed in Project directory and content.pm (module) is placed in Project/utils directory. Now I want to use content.pm in main.pl I made…
Developus
  • 986
  • 1
  • 12
  • 27
0
votes
1 answer

Placing function in .dll causes debug assertion failed error

Hallo fellow members, I run into a very strange problem today and I am not exactly sure as to what is causing it. Here is a function which I use to get the current working directory : #ifdef _WIN32 #include #define GetCurrentDir…
0
votes
1 answer

pycharm os.listdir does not list contents

I am a SO virgin. Treat me gently. In Python3.5 I can run: import os os.listdir('C:/Users/Tim0t_000/Desktop/python automate boring downloads') and this produces the list of files contained in that directory. If I run the same script in Pycharm, it…
Tim0th1
  • 57
  • 8
0
votes
1 answer

How can I use process.cwd() within Angular2 Component with TypeScript?

How can I use process.cwd() within Angular2 Component with TypeScript? What do I have to import? The following in the constructor console.log("Where I am: ", process.cwd()); outputs the error: ORIGINAL EXCEPTION: ReferenceError: process is not…
user2227400
0
votes
1 answer

Consistently Getting Null Value in C String using getcwd

I am trying to make a simple program that just writes your working directory to a file, and I cannot, for the life of me, figure out what I am doing wrong. No matter what I do, my buffer is storing null after my call to getcwd(). I suspect it may…
Ronald
  • 11
  • 3
0
votes
1 answer

Get the original location where the program is called

Is there any way to know the directory where the program is originally spawned in C? I want my program to know where it is located in the computer. I already tried using _getcwd() in direct.h. I also tried getcwd() using unistd.h. But here's the…
Bryan James
  • 65
  • 2
  • 11
0
votes
1 answer

_fullpath Giving Hex Value in Visual Studio C++

I'm trying to find out what my crrent working directory is. I've tried using both _fullpath and _getcwd as part of . However, all it gives me is an 8-byte hex value (such as 5504CA90). Why is it giving me this, and how can I get the…
0
votes
0 answers

How to format filepath with spaces in Mac OSX C++

I am trying to use the stat() function in a C++ program I'm writing for Mac OS X. the stat() function fails to find this directory: /Users/devuser/git/thisprogram/build/Release/ABC USER Testing App.app/Contents/Resources But it is able to find this…
gonzobrains
  • 7,198
  • 11
  • 73
  • 126
0
votes
0 answers

iOS getcwd alternative

I am porting my C++ OpenGL application to iOS, it uses getcwd function to load shaders. In iOS 'getcwd' returns just a slash and I can't do something. Or is there any good method to load files on iOS? Edit: found a solution! POSIX-based code.…
Neko Code
  • 468
  • 14
  • 20
0
votes
3 answers

Performance of GNU C implementation of getcwd()

According to the GNU Lib C documentation on getcwd()... The GNU C Library version of this function also permits you to specify a null pointer for the buffer argument. Then getcwd allocates a buffer automatically, as with malloc(see Unconstrained…
JasonM
  • 21
  • 1