Trying to read file but not finding the path? - grails

Question/Answer Read a file in groovy into a string is simple, except I get a FileNotFound exception no matter where I move the file, e.g. even to the root directory on a linux box.
If I do:
String cpni = new File('/cpni_p').text
and the file cpni_p resides right in the root directory of the system (i.e. make it as simple as possible), I get a
FileNotFoundException: \cpni_p (the system cannot find the file specified)
How do I fix this? I'm open to direct Java too -- just want to get it to work.

There was a directory level privilege problem.

Related

Where should the erlang_ls.config go

I want to use coc.nvim and elrang_ls in vim8.2. There are some problems. It report missing an erlang_ls.config when I open a erlang file. But i have erlang_ls.config in project root.
the result of CocCommand workspace.showOutput show it read config from unexpected place
Where is correct position for erlang_ls.config?
Sorry for my poor English. Thanks.
It is possible to customize the behaviour of the erlang_ls server via
a configuration file, named erlang_ls.config. The erlang_ls.config
file should be placed in the root directory of a given project to
store the configuration for that project.
According to the picture, the clue has already been given to you. In the els_config.erl file consult_config function, line 126. error type = 2.
I think the information is enough, you can find source code file and read it and find why?
It is need create erlang_ls.config in C:\Users\Administrator\AppData\Roaming\erlang_ls and erlang_ls.config erlang_ls.yaml in the project root path. But I don't know why.

Erlang : exception error: no match of right hand side value {error,enoent} while reading a text file

I am currenly working on an erlang project and stuck in reading the file. I want to read a text file which is in the /src folder where all the erlang and a text file are in the same structure. Then too, I am not being able to read the file despite of specifying file paths. Any help would be appreciated.
start() ->
{ok,DataList} = file:consult("Calls.txt"),
io:format("** Calls to be made **"),
io:fwrite("~w~n",[DataList]).
The data file stores contents like : {john, [jill,joe,bob]}.
Try add folder name to the path or try set full patch to the file:
1> {ok,DataList} = file:consult("src/Calls.txt").
Notes: the error {error,enoent} mean that the file does not exist or you don't have a rights to read/write current file, for this case need set 777 rights or similar.
If you need to use src/call.txt, then this simply means that your IDE (or you) has created a src folder in which the calls.txt file has been placed. At the same time, the IDE is using a path that only includes the top level folder (i.e., the root folder for the IDE project). So src/call.txt must be used in that case. This isn’t a problem with Erlang, or even the IDE. It’s just the way your project is set up.
You can do either of two things. Move the calls.txt file up one level in the IDE file manager, so that it can be referenced as calls.txt, not src/call.txt. You can also just change the path to “calls.txt” before you run it from the command line.
enoent means "Error: No Entry/Entity". It means the file couldn't be found. When I try your code, it works correctly and outputs
[{john,[jill,joe,bob]}]

How can I check the file exists in Network UNC path in ruby?

I have a text box where the user can type the UNC path like '\\server_name\testing\'
How can I check this UNC path exists?
I have tried lot of options from the File and Directory and did not get any clue.
My current code is
def get_files(path)
Dir.entries(path).select {|f| File.file?(f)}
end
When I tried to access get_files('\\server_name\testing\'). I got No such file or directory - No such directory: \\server_name\testing\
When I try to access through windows explorer it exists.
Thanks
Make sure your working directory is set properly, because your path will be considered relative to it. You can use Dir.pwd to get your working directory and Dir.chdir to change it.
\\server_name\testing is path to SAMBA resource, so you can't use standard ruby File IO.
Use smbclient to check path or sambal (wrapper around smbclient).

Relative path in Lua script failing

So, here's one of those too-simple-to-fail bugs that we all hate.
I have a .lua file that, among other things, tries to load an image via Love's newImageData function (and place it into a button):
back_button = buttonmanager.createButton("back", love.image.newImageData("../Images/BackButton.png"), width-200, height-105)
Love fails to load, throwing this error:
./frame.lua:5: Could not open file ../Images/BackButton.png. Does not exist.
I've gone through the stupid-mistakes process ("well, does it actually exist? Where is the folder?" etc) -- the file exists, is in the Images folder, which is one level up -- I can even say "ls ../Images/BackButton.png" from the directory this script sits in, and it outputs BackButton.png as I'd expect.
Is there some weird relative pathing issue I need to watch out for? I tried changing it to an absolute path and it gave me the same error.
The love.filesystem module restricts access to files in certain locations:
This module provides access to Files in two places, and two places only:
* The root folder of the .love-file. (Alternatively a directory).
* The root folder of the write directory.
Is the ../Images directory outside of your game's folder/archive?

Relative path of a given file from a service application in Delphi

I have a problem loading a file, as I'm passing a relative path to the function FileExists(Filename: String) and it's returning false, that is, it does not find the file in the directory that I pass.
I have a file named Template.html in the D:\Programming\Delphi\Projects\SendMail directory, and a service written in Delphi whose .EXE is in the D:\Programming\Delphi\Automation directory. I am passing the relative path: .\..\Projects\SendMail\Template.html to FileExists(), but it's returning that the file does not exist.
I think that has something to do with the relative path of a service and the relative path of the application being different. Can anybody help me with this?
As lorenzog said, try specifying the full path.
You can also try to set the currentdir to your likings.
//sets currentdir to your application.exe dir
SetCurrentDir(ExtractFileDir(ParamStr(0)));
You assume that the current directory of the service is the directory the executable is stored in. Call GetCurrentDir to find out the current directory.
My experience has been that services start with a working folder of %SystemRoot%\System32 no matter where the actual executable is located.
The way that I have got around this limitation is to write a registry key during installation of the service (e.g. HKLM\SOFTWARE\MyCompany\MyApp\INSTALL_PATH) that points to what I would like the working folder to be. Then when the service starts, it grabs the data from the registry and uses that value as the base when creating paths to files.

Resources