How can I prevent AccessDeniedException during Files.walkFileTree? - file

I'm trying to use Java 1.7 nio. When I call
Files.walkFileTree(source[i], tc);
where source[i] is any folder on my Windows file system and tc is a SimpleFileVisitor, I get an java.nio.file.AccessDeniedException. I've checked the folder and the folder contents and ensured that read, write, and execute are allowed for all users.
I can access the file fine using File. Why does walkFileTree have a problem accessing the file?

I found the solution to this issue. I overrode the visitFile method and it was incorrectly referencing a file path.

Related

Quicktime Error opening random files using simple apple script

I'm getting the following error:
"The file isn’t compatible with QuickTime Player."
When using this script:
tell application "Finder"
set random_file to some file of entire contents of folder "Movies" of home
open result
end tell
However, I am able to open the file from the finder manually and once I do the script works on just that file. The problem is I have thousands of files and don't want to open each one manually for the script to work again. Have not had this problem with the script in the past.
There are two ways I can think of to approach modifying your script:
Stick with Finder's open command but invoke it fully with its using parameter, which accepts an application file that informs Finder of the application that will be used to open the file. It may sound superfluous given it already tries to open it in QuickTime, and we're not trying to change that, but it's not unwise to see if it does confer a difference in behaviour:
tell application id "com.apple.finder"
tell the folder (path to movies folder) to tell (the ¬
a reference to entire contents) to tell (the ¬
some document file as alias) to set f to it
open f using application file id "com.apple.QuickTimePlayerX"
end tell
Grab the file as you like (really, you ought to be using System Events for this, not Finder, but I'll go with what you had), but then use the open handler of the specific application to open the file:
tell application id "com.apple.finder" to tell the folder (path to movies folder) ¬
to tell (a reference to the entire contents) to tell (some document file) ¬
as alias to set f to it
tell application id "com.apple.QuickTimePlayerX"
activate
open f
end tell
NB. I'm using Monterey, in which both of these two above propositions work appropriately. This doesn't necessarily infer that it will do so in Big Sur, but if they do not, it's worth checking the various app permissions under the different Security & Privacy headings of System Preferences.

Loading files into MAGMA

I'm trying to load files into MAGMA and am running into some trouble. Ostensibly, the command load "filename";should be sufficient. I've attempted, but keep getting the same result:
>> load "filename";
^
User error: Could not open file "filename" (No such file or directory)
The file is saved in my documents folder, so I'm not sure what the issue is. Do I have to specify the path? Save the file in a particular place?
I've tried reformatting, using both txt and rtf files, so I don't think that's the issue.
For loading file in MAGMA you can place your file in installed place folder. For example: C:\Program Files (x86)\Magma
Also if your file have an special format you should mention it.
Suppose You want loading a txt file with name a. with load"a"; you face with error. You must type load"a.txt";.
Try using GetCurrentDirectory() command to find your current directory location. And then you can use SetPath() to change where MAGMA has to be to search for your file. This will fix it.

Getting cannot find file exception in Play Framework

I have a file called product.csv in my application root. I want to read from the file. But I am getting file not found exception. Here is the code I have written.
val lines = scala.io.Source.fromFile("/product.csv").mkString
println(lines)
What am I doing wrong?
I am using Windows OS.
You need to use a relative filepath "product.csv" rather than "/product.csv" which will look at the root of your drive.

rename a file using C function rename()

I'm using a Mac. I need to rename a file in the /Library/Application Support/AppName/filename.aiff
This is the system library and not /User/username/Library...
I'm using the rename(old name, new name) function. This function doesn't work (even though it doesn't return an error) if I place the file in the /Library/Application Support/AppName directory but it works properly if I place the file, for example, in /User/username/Documents/filename.aiff.
I don't know what the problem is. Any help would be appreciated. Thanks!
You don't own the directory you're trying to move files into:
/Users/Username/... is a user owned directory, so you're allowed to manipulate files there.
/Library is not a user owned directory.
In order to manipulate files in a non-user owned directory you would need elevated permissions. Instead of using /Library you should be using ~/Library, which is the user owned directory. ~/Library is the shorthand name for /Users/Username/Library.
If the rename is working fine in other path means the problem should be related to permission to access file or with the path searched for file.

GM:Studio - *.ini files doesn't load/save

So i'm trying to make a configuration for my app, although it doesn't seem to load or save anything from/in it.
Here's the code upon creation:
ini_open(working_directory + "\properties.ini");
global.width = ini_read_real('screen','width',640);
global.height = ini_read_real('screen','height',480);
ini_close();
Here's the ini file:
[screen]
width = 1280
height = 1024
when i return global.width and global.height values they're still 640;480 but not as stated in the ini file, which means it doesn't even load values from the file. I was wondering, maybe I need to compile the executable and then run it as administrator, but I doubt that there could be a problem with permissions. I also added properties.ini file to "Included Files" folder so it would come with compiled exe.
This seems weird, but now it works. Actually the *.ini file isn't saved the same place where exe is. I just found out that it saves everything in %localappdata%// . Also it looks to be working better without dir shortcut "working_directory". So thanks, anyway

Resources