home-directory

C snprintf specify user home directory

巧了我就是萌 提交于 2019-12-18 09:44:42
问题 I use snprintf to write formatted data to disk, but I have one problem, how do I save it to the user's home directory? snprintf(filename, sizeof(filename), "%s_%s.sho", client, id); 回答1: On Linux and POSIX systems the home directory is often from the HOME environment variable. So you might code snprintf(filename, sizeof(filename), "%s/%s_%s.sho", getenv("HOME"), client, id); Pedantically the getenv(3) could fail (or be wrong). But that rarely happens. See environ(7). (You might check, and or

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

流过昼夜 提交于 2019-12-17 16:03:53
问题 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? 回答1: ~ is a

Android Get Application's 'Home' Data Directory

浪子不回头ぞ 提交于 2019-12-17 08:30:10
问题 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()

Linux VSFTPD : Jail a “Specific SFTP User” to its home?

拈花ヽ惹草 提交于 2019-12-14 04:08:41
问题 I'm using both Redhat and CentOS. I previously wanted to jail a "Specific User" to its home. Then i got it by following this answer. When the user (lets say, using FileZilla) use: Protocol: FTP .. it is fine! But again there, when the user connects with: Protocol: SFTP (in the FileZilla setting) .. the Jailing for that Specific User is NOT working anymore. Can still browse through. How can i make it to have: In vsFTPd , jail a Specific User to its home when using Protocol: SFTP . Thank you!

Swift: How to expand a tilde in a path String

独自空忆成欢 提交于 2019-12-14 03:40:41
问题 How can I expand a path String with a tilde in Swift? I have a string like "~/Desktop" and I'd like to use this path with the NSFileManager methods, which requires the tilde to be expanded to "/Users/<myuser>/Desktop" . (This question with a clear problem statement doesn't exist yet, this should be easily findable. Some similar but not satisfying questions are Can not make path to the file in Swift, Simple way to read local file using Swift?, Tilde-based Paths in Objective-C) 回答1: Tilde

How te set diffrent homedirectories for multiple OUs?

社会主义新天地 提交于 2019-12-13 01:28:48
问题 I'm building a script that checks if the homedirectory of the users are correct and if not set the correct path. OU-1 has a diffrent path than OU-2 and some users are an exception. But the script isn't working. This is what I got so far: $folderpath = "\\172.16.32.27\gebruikers\homedir\", "\\172.16.32.27\share\homedirectories\" $homedrive = "H" $SearchBase = "OU=test,DC=Test,DC=org", "OU=users,DC=Test,DC=org" $domain = "test.org" $excludes = @("test", "user22") $i = 0 $filter3 =

Getting current user home directory on OS X?

北慕城南 提交于 2019-12-13 00:47:19
问题 How to find current user home directory on OS X? HOME environmental variable is not always set, for example when you do not run in console (GUI apps). For this reason I'm looking for a generic solution, one that will fall-back if os.environ['HOME'] is not set. There is a similar question (C) but it already has an accepted solution that is invalid. A Python solution would be preferred but other languages are welcome as long they provide a valid home or at least one location where you can write

IOS: error in HomeDirectory

自古美人都是妖i 提交于 2019-12-12 04:00:13
问题 I have this code NSString *nextSequentialFile = [filePath stringByReplacingOccurrencesOfString:photoNumber withString:[NSString stringWithFormat:@"%d", (index + 1)] options:NSBackwardsSearch range:[filePath rangeOfString:photoNumber options:NSBackwardsSearch]]; but I have this error and I don't understand beacuse it happens. Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFString replaceOccurrencesOfString:withString:options:range:]: Range or index out of

What is the Windows equivalent of pwd.getpwnam(username).pw_dir?

馋奶兔 提交于 2019-12-09 16:11:25
问题 The Python pwd module provides access to getpwnam(3) POSIX API, which can be used to get the home directory for a particular user by username, as well determining if the username is valid at all. pwd.getpwnam will raise an exception if called with a non-existent username. At first it seems like the same result can be achieved in a cross-platform manner via os.path.expanduser('~username') . However, it appears that with Python 2.6 on Windows XP this won't actually produce a failure for a non

How to make babun/cygwin home directory equal windows home directory?

让人想犯罪 __ 提交于 2019-12-07 05:53:45
问题 I just installed babun, a variant of Cygwin. I want the cygwin user home directory to equal my windows home directory. So, to be clear, I don't want to add the cygwin home to the C:\Users as a new user, I want it to be the same as my current windows home directory. Now, according to this post, How can I change my Cygwin home folder after installation?, there is a neat way to make the cygwin home directory point to your windows home directory. You open the file /etc/nsswitch.conf and make sure