file-permissions

How to get File Permission Mode programmatically in Java

て烟熏妆下的殇ゞ 提交于 2019-11-29 14:32:33
I know it is possible to change the permission mode of a file using: Runtime.getRuntime().exec( "chmod 777 myfile" ); . This example sets the permission bits to 777 . Is it possible to set the permission bits to 777 programmatically using Java? Can this be done to every file? Using chmod in Android Java doesn't have native support for platform dependent operations like chmod. However, Android provides utilities for some of these operations via android.os.FileUtils. The FileUtils class is not part of the public SDK and is therefore not supported. So, use this at your own risk: public int chmod

Grant IIS Express permission to access network drive in VMWare

白昼怎懂夜的黑 提交于 2019-11-29 14:18:07
I have a Windows 7 virtual machine in VMWare that I'm using to develop ASP.NET MVC 5 Web applications with the default IIS Express server. I like to keep my projects saved on an external hard drive which I can access in the virtual machine through a shared folder / network drive. However, when I run my applications, IIS Express cannot access my web.config files in the project directory. It's looking in the right folder so I'm pretty sure this is a permissions issue. How can I grant IIS Express file access to the files on my network drive? Things I've tried Running Visual Studio as an

fopen Permission denied on a file with 777 permissions

五迷三道 提交于 2019-11-29 14:03:06
Since the title of this post is pretty much self-explanatory, I'll just jump to the code : echo sprintf('%o', fileperms('test.txt'))."<br/>"; fopen("test.txt", "w"); And with this I get : 100777 fopen(test.txt): failed to open stream: Permission denied Any ideas ? Edit : Problem solved : there were access control lists on the server that were not configured correctly. Thanks ! DanFritz I think its possible that you have write/read permissions on the file but not on the folder. Try this in the public root of your website and see if you can read or write the file. For safe mode ( http://php.net

File ownership/group is changed when users push to a GIT repository

廉价感情. 提交于 2019-11-29 12:01:51
问题 For over a year, I've been having troubles with GIT and directory/file permissions. I have a central repository to which multiple developers push code, using ssh (origin set up as ssh://example/git/repository). I have set up the repository as follows: 1) My config file in the central repository: [core] repositoryformatversion = 0 filemode = true bare = true sharedrepository = 0660 2) All repository directory permissions are set to 770 (rwxrwx---) 3) All files in ./objects/XX and ./objects

Recursively chmod/chown/chgrp all files and folder within a directory

﹥>﹥吖頭↗ 提交于 2019-11-29 10:22:10
I am working on a site which builds other sites. Some if it I use copy() to create the files and directories, other times I'm building XML files in php and using DOMDocument::save to save them. The end result is a root folder with all sorts of messed up permissions. I've beening modding files and folders as I go, which words to some extent, but I'm particularly having trouble when it comes to using copy() . (This is where I'm at so far http://pastebin.com/SBE8vtFX , attn: function modPath($path) ) I want to take a different approach and recursively chmod/chown/chgrp all the files and folders

PowerShell folder permission error - Some or all identity references could not be translated.

♀尐吖头ヾ 提交于 2019-11-29 09:30:20
I have read many posts about this, but I still can't get it. I am running this script as Admin and It does create the folders requred, just does not set the appropriate permissions. Any help would be appreciated. Thank you! $Users = Get-Content "D:\New_Users.txt" ForEach ($user in $users) { $newPath = Join-Path "F:\Users" -childpath $user New-Item $newPath -type directory $UserObj = New-Object System.Security.Principal.NTAccount("DOMAIN",$user) $acl = Get-Acl $newpath $acl.SetAccessRuleProtection($True, $False) $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("O1OAK\

How can I programmatically determine if I have write privileges using C# in .Net?

北慕城南 提交于 2019-11-29 07:39:48
How can I determine if I have write permission on a remote machine in my intranet using C# in .Net? The simple answer would be to try it and see. The Windows security APIs are not for the faint of heart, and may be possible you have write permission without having permission to view the permissions! Been there too, the best and most reliable solution I found was this: bool hasWriteAccess = true; string remoteFileName = "\\server\share\file.name" try { createRemoteFile(remoteFileName); } catch (SystemSecurityException) { hasWriteAccess = false; } if (File.Exists(remoteFileName)) { File.Delete

git deploying project - file permissions - (chmod)

混江龙づ霸主 提交于 2019-11-29 07:16:57
I'm deploying my project with git to a remote server using a post-update hook. More specifically I'm following these steps . Everything on my local copy has the right permissions, however after deploying with git push production , files that are set to 777 change in the remote server to -rwxr-xr-x I've added to both (local/remote) .git/config the core variables filemode = false and I've changed as well my umask in /etc/profile to 0002 Any ideas why it keeps changing the mode of files? Thanks The core.filemode variable is only used when files are indexed. When git checks out files, the stored

Set File Permissions in C#

流过昼夜 提交于 2019-11-29 07:05:45
I wanna set the permissions on a file to "can not be deleted" in C#, only readable. But I don't know how to do this. Can you help me ? Take a look at File.SetAttributes() . There are lots of examples online about how to use it. Taken from that MSDN page: FileAttributes attributes = File.GetAttributes(path); if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { // Show the file. attributes = RemoveAttribute(attributes, FileAttributes.Hidden); File.SetAttributes(path, attributes); Console.WriteLine("The {0} file is no longer hidden.", path); } else { // Hide the file. File

File.Move does not inherit permissions from target directory?

让人想犯罪 __ 提交于 2019-11-29 06:28:11
问题 In case something goes wrong in creating a file, I've been writing to a temporary file and then moving to the destination. Something like: var destination = @"C:\foo\bar.txt"; var tempFile = Path.GetTempFileName(); using (var stream = File.OpenWrite(tempFile)) { // write to file here here } string backupFile = null; try { var dir = Path.GetDirectoryName(destination); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); Util.SetPermissions(dir); } if (File.Exists(destination)) {