home-directory

Getting home directory in Mac OS X using C language

社会主义新天地 提交于 2019-11-28 00:23:55
问题 How can I get the path of home directory in Mac OS X using C language in XCode editor. 回答1: #include <stdlib.h> #include <stdio.h> int main(void) { const char *homeDir = getenv("HOME"); if (homeDir) printf("Home directory is %s\n", homeDir); else printf("Couldn't figure it out.\n"); return 0; } 回答2: This should work under Linux, Unix and OS X, for Windows you need to make a slight modification. #include <stdlib.h> #include <stdio.h> #include <pwd.h> #include <unistd.h> int main(void) { const

How do I find a user's home directory in Perl?

▼魔方 西西 提交于 2019-11-27 20:58:45
I need to check whether a file in a user's home directory exists so use file check: if ( -e "~/foo.txt" ) { print "yes, it exists!" ; } Even though there is a file called foo.txt under the user's home directory, Perl always complains that there is no such file or directory. When I replace "~" with /home/jimmy (let's say the user is jimmy) then Perl give the right verdict. Could you explain why "~" dosen't work in Perl and tell me what is Perl's way to find a user's home directory? ~ is a bash -ism rather than a perl -ism, which is why it's not working. Given that you seem to be on a UNIX-type

What is the alternative for ~ (user's home directory) on Windows command prompt?

断了今生、忘了曾经 提交于 2019-11-27 17:15:55
I'm trying to use the command prompt to move some files, I am used to the linux terminal where I use ~ to specify the my home directory I've looked everywhere but I couldn't seem to find it for windows command prompt ( Documents and Settings\[user] ) You're going to be disappointed: %userprofile% You can use other terminals, though. Powershell, which I believe you can get on XP and later (and comes preinstalled with Win7), allows you to use ~ for home directory. You can %HOMEDRIVE%%HOMEPATH% for the drive + \docs settings\username or \users\username . You can use %systemdrive%%homepath%

How can I find the user's home dir in a cross platform manner, using C++?

不想你离开。 提交于 2019-11-27 10:31:43
问题 How can I find the user's home directory in a cross platform manner in C++? i.e. /home/user in Linux, C:\Users\user\ on Windows Vista, C:\Documents And Settings\user\ on Windows XP, and whatever it is that Macs use. (I think it's /User/user) Basically, what I'm looking for is a C++ way of doing this (example in python) os.path.expanduser("~") 回答1: I don't think it's possible to completely hide the Windows/Unix divide with this one (unless, maybe, Boost has something). The most portable way

Node.js - Find home directory in platform agnostic way

 ̄綄美尐妖づ 提交于 2019-11-27 10:24:20
Process.platform returns "win32" for Windows. On Windows a user's home directory might be C:\Users[USERNAME] or C:\Documents and Settings[USERNAME] depending on which version of Windows is being used. On Unix this isn't an issue. As mentioned in a more recent answer , the preferred way is now simply: const homedir = require('os').homedir(); [Original Answer] : Why not use the USERPROFILE environment variable on win32? function getUserHome() { return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; } os.homedir() was added by this PR and is part of the public 4.0.0 release

Android Get Application's 'Home' Data Directory

孤者浪人 提交于 2019-11-27 06:40:00
A simple question, relating to the default 'home' directory when an app writes to the internal memory. By default, any files created are placed by the OS (2.2) in: /data/data/your.package/files When reading in files, the same default is used, when keeping in proper context via openFileInput() , openFileOutput() . But if I need to check file existence, for instance, using the File class, I need to specify the whole path in the constructor. I see there are Environment.getDataDirectory() (returns /data ), Environment.getRootDirectory() (returns /system ), etc, but nothing related to getting the

Meaning of tilde in Linux bash (not home directory)

给你一囗甜甜゛ 提交于 2019-11-26 23:58:58
问题 First off, I know that ~/ is the home directory. CDing to ~ or ~/ takes me to the home directory. However, cd ~X takes me to a special place, where X seems to be anything. In bash, if I hit " cd ~ " and hit tab, it shows a bunch of possible ~X options like ~mail and ~postgres and ~ssh . Going to those folders and doing a pwd shows me that these folders are not in the home directory; they're all over the place. They are not aliases. I've checked. They're not env. variables, or else they'd

What is the alternative for ~ (user&#39;s home directory) on Windows command prompt?

旧时模样 提交于 2019-11-26 15:16:10
问题 I'm trying to use the command prompt to move some files, I am used to the linux terminal where I use ~ to specify the my home directory I've looked everywhere but I couldn't seem to find it for windows command prompt ( Documents and Settings\[user] ) 回答1: You're going to be disappointed: %userprofile% You can use other terminals, though. Powershell, which I believe you can get on XP and later (and comes preinstalled with Win7), allows you to use ~ for home directory. 回答2: You can %HOMEDRIVE%

How to find the real user home directory using python?

我与影子孤独终老i 提交于 2019-11-26 13:27:59
I see that if we change the HOME(linux) or USERPROFILE(windows) environmental variable and run a python script, it returns the new value as the user home when I tried, os.environ['HOME'] os.exp Is there any way to find the real user home directory without relying on the environmental variable? edit: Here is a way to find userhome in windows by reading in the registry, http://mail.python.org/pipermail/python-win32/2008-January/006677.html edit: One way to find windows home using pywin32, from win32com.shell import shell,shellcon home = shell.SHGetFolderPath(0, shellcon.CSIDL_PROFILE, None, 0) I

Fix msysGit Portable $HOME location

a 夏天 提交于 2019-11-26 12:17:07
问题 I have successfully installed and configured msysGit Portable on my flash drive, and have used it to pull and push GitHub repos. However, I seem to always have to kludge the SSH support. Specifically, in order for SSH to find my key files, I have to follow these instructions to start a second instance of ssh-agent and then ssh-add my key every time I run git-bash.bat. Using the output of ssh -v git@github.com to debug I see that msysGit defaults to my Windows user directory to look for keys.