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);
104 questions
0
votes
3 answers

Obtain the name of the current directory (not the path)

I had seen, and I had used a couple of time the function cwd() to get the absolute path of a folder, but there's a question, and that's if it's possible with C to get just the name of a folder. For example, let's suppose that I execute a program on…
SealCuadrado
  • 749
  • 1
  • 10
  • 21
0
votes
1 answer

Unix Shell in C - Change Directory

I'm another CS beginner working on a simple Shell. At the moment I am trying to change the current directory if an argument is passed, else, report to the current directory. I tried using chdir() in my program, but it's apparently not working. I…
Gus
  • 215
  • 1
  • 6
  • 16
0
votes
1 answer

php getcwd() - exclude server directories

I have the following line of code which works on my local machine because the root directory of the server is the same as the root directory of the site. $directories = explode("/", str_replace($_SERVER['DOCUMENT_ROOT'] . "/", "", getcwd())); How…
Tom
  • 12,776
  • 48
  • 145
  • 240
0
votes
1 answer

PHP getcwd() function to be used with include or require in different directories

I need to include a path from a config file in one directory on other scrpits a few directories up or down. My config file has a function like this: $execute_path = getcwd() . "/execute.php"; The execute.php file resides in the same directory as…
Chris81
  • 426
  • 2
  • 4
  • 16
0
votes
1 answer

gcc throws: undefined reference to `_getcwd'

I'm trying to compile this sourceforge-project in ubuntu 11.10 x64: http://vmb.sourceforge.net/ Linux users have to compile the devices from sources. Either obtained from cvs (see: http://sourceforge.net/projects/vmb/) or as a tgz file. The sources…
Reini
  • 1,233
  • 3
  • 19
  • 34
-1
votes
3 answers

What is the meaning of the getcwd() method?

import os cwd = os.getcwd() df.to_csv(cwd+ "/BA_reviews.csv") I didn't understand this code properly. Can someone help?
-1
votes
1 answer

python os.getcwd() unexpected

import os dir_name = "new_dir" os.mkdir(dir_name) os.chdir(dir_name) print("THE cwd now is in " + os.getcwd()) os.rmdir("../"+dir_name) print(dir_name+" deleted") print("Checking CWD") print("THE script now is in…
-1
votes
2 answers

How do I change my working directory in a proper manner?

I'm working in Google Colab and I'm trying to change to working directory to my desktop (desktop = bureaublad in dutch thats why you see 'bureaublad in my path). However, changing the working directory keeps giving me the error that such a directory…
-1
votes
3 answers

Is there any alternative API for getcwd to get the working direcory of process

In our application we call getcwd(3) to get the current working directory. When the process starts running, if anyone deletes the directory path, then the process is running but getcwd API fails (returns NULL). Example: Process name is: a.exe …
Syedsma
  • 1,183
  • 5
  • 17
  • 22
-1
votes
1 answer

os.getcwd() returns a slash (/)

I have a python 3.6 script that I wrote in Atom editor on macOS. The script uses os.getcwd() routinely and has always worked fine. I restarted my computer last night, updated the Atom packages, and suddenly it broke. Using a print statement,…
Kieran Paddock
  • 375
  • 1
  • 5
  • 15
-1
votes
1 answer

php inserting link parts into http

I am trying to retrieve parts of the getcwd() method and inserting them into window.open() the current getcwd() gives me this C:\wamp\www\qa4u\qa4u_working\Presenter Using this code :
-2
votes
1 answer

How do I get the current dir and assign it to a variable in linux

I new to program, currently I followed pwd tutorial and came out the code below. I need to assign a variable to hold the current directory, and join it with other file as below. #include #define GetCurrentDir getcwd main ( uint port,...…
Alois
  • 130
  • 1
  • 2
  • 14
-2
votes
2 answers

can't unlink image which is in url format

php is getting image in following format, while echoing $_POST['img'] http://localhost/uploads/images/1533033949-8.jpg But why unlink doesn't working - // Get src. $img = $_POST["img"]; // Check if file exists. if (file_exists(getcwd() . $img))…
Dipak
  • 931
  • 14
  • 33
-6
votes
2 answers

In what circumstances does getcwd() return NULL?

char cwd[256]; if (getcwd(cwd, sizeof(cwd)) == NULL) { return -1; } First comes to mind that getcwd() could return NULL, when cwd is not large enough. Is there any other cases?
user849204
1 2 3 4 5 6
7