I have this logical location: |project://testProject/src/style.css| which I would like to convert to its related physical location. The location is first passed on to a Java file, where I try to convert it using the URIResolverRegistry.getInstance().logicalToPhysical(theLoc); method. The only problem is that it returns the exact location I passed it (the logical location). So it does not get converted. How come? Am I missing something? Or is there maybe another way to solve this?
Actually, project is supposed to be a "physical" URI already. If you want to convert it to an absolute path on the file system, then this is not supported directly.
However, if you are in an Eclipse context and you are free to depend on it, then rascal-eclipse offers this API:
IFile file = new ProjectURIResolver().resolveFile(myLoc);
String absolutePath = file.getLocation().toOSString();
Related
I have a script which saves some files at a given location. It works fine but when I send this code to someone else, he has to change the paths in the code. It's not comfortable for someone who does not know what is in that code and for me to explain every time where and how the code should be changed.
I want to get this path in a variable which will be taken from the configuration file. So it will be easier for everyone to change just this config file and nothing in my code. But I have never done this before and could not find any information on how I can do this in the internet.
PS: I do not have any code and I ask about an ultimate solution but it is really difficult to find something good in the internet about dxl, especially since I'm new with that. Maybe someone of you already does that or has an idea how it could be done?
DXL has a perm to read the complete context of a file into a variable: string readFile (string) (or Buffer readFile (string))
you can split the output by \n and then use regular expressions to find all lines that match the pattern
^\s*([^;#].*)\s*=\s*(.*)\s*$
(i.e. key = value - where comment lines start with ; or #)
But in DOORS I prefer using DOORS modules as configuration modules. Object Heading can be the key, Object Text can be the value.
Hardcode the full name of the configuration module into your DXL file and the user can modify the behaviour of the application.
The advantage over a file is that you need not make assumptions on where the config file is to be stored on the file system.
It really depends on your situation. You are going to need to be a little more specific about what you mean by "they need to change the paths in the code". What are these paths to? Are they DOORS module paths, are they paths to local/network files, or are the something else entirely?
Like user3329561 said, you COULD use a DOORS module as a configuration file. I wouldn't recommend it though, simply because that is not what DOORS modules were designed for. DOORS is fully capable of reading system files in one line at a time as well as all at once, but I can't recommend that option either until I know what types of paths you want to load and why.
I suspect that there is a better solution for your problem that will present itself once more information is provided.
I had the same problem, I needed to specify the path of my configuration file used in my dxl script.
I solved this issue passing the directory path as a parameter to DOORS.exe as follow:
"...\DOORS\9.3\bin\doors.exe" -dxl "string myVar = \"Hello Word\"
then in my dxl script, the variable myVar is a global variable.
I am trying to incorporate F# SQLProvider into my project. And for now I can successfully access the Postgresql database. But there is something called resolution path. That I need to give. Now, the question is path will be different for deployed application and application I am developing on my local machine. So, how can I give relative path to my dll.
Right now I am using below path
[<LiteralAttribute>]
let resolutionFolder = #"D:\<myprojectdirectory>\<projectname>\packages\Npgsql.2.2.2\lib\net45"
So, is it possible to convert to something like
[<LiteralAttribute>]
let resolutionFolder = #"..\sqlprovider\packages\Npgsql.2.2.2\lib\net45"
Now, in Azure site I don't which path it will be. So, above path is not fix. But if I can give relative path that will be better solution I guess.
Let me know if any further details are required.
It would seem like you could use conditional preprocessor directives to help you here.
[<Literal>]
let resolutionFolder =
#if DEBUG
#"D:\<myprojectdirectory>\<projectname>\packages\Npgsql.2.2.2\lib\net45"
#else
#"..\sqlprovider\packages\Npgsql.2.2.2\lib\net45"
#endif
When you define your SqlDataProvider type, you provide the connection string and resolution path. This is required at design time so that it can generate the types you need. Eg:
type sql = SqlDataProvider<
"<design-time connection string>",
DatabaseVendor = Common.DatabaseProviderTypes.SQLITE,
ResolutionPath = "<design-time path>">
When you use the sql type, you call the sql.GetDataContext function. This function has overloads, one of which allows you to provide the connection string and the resolution path as strings. These values will override what was provided when the type was defined.
let ctx = sql.GetDataContext("<RealConnectionString>", "<RealResolutionPath>")
Because these strings to GetDataContext are not needed at design time, you can source them from a configuration file, or an Environment variable, etc. You can then have settings for development vs settings for production.
I'm not sure where your resolution path will need to point in Azure, but by using something like an environment variable it should be simple to update as needed.
I want to deploy a pre compiled EAR on openshift.com but sadly I get some exceptions.
In the logs I can see that the line:
System.getProperty("jboss.server.config.url")
returns a null
But when I print out the line (only for testing)
System.getProperty("jboss.server.config.dir")
Im getting a path.
The funny part is that my local computer (JBossAS 5) prints out the opposite:
System.getProperty("jboss.server.config.url") -> path
System.getProperty("jboss.server.config.dir") -> null
So is there any way how I can set the config.url?
And is there any differences between these two properties?
If yes, I could easily replace the line, but otherwise I don't want two different EAR's
(local and openshift.com).
Thank you and sorry for my bad english
Your code looks reasonable. I would try calling system.getenv without a parameter to get the full mapping then scan through that and see what it contains. Also make sure the environment variable is set globally (or at least in the context where you are executing.)
Map mp = System.getenv();
mp.get("JBOSS_CONFIG_DIR")+"/"+filename
I have a file that describes input data, which is split into several other files. In my descriptor file, I first give the path A that tells where all the other files are found.
The originator may set either a relative (to location of the descriptor file) or absolute path.
When my program is called, the user gives the name of the descriptor file. It may not be in the current working directory, so the filename B given may also contain directories.
For my program to always find the input files at the right places, I need to combine this information. If the path A given is absolute, I need to just that one. If it is relative, I need to concatenate it to the path B (i.e. directory portion of the filename).
I thought boost::filesystem::complete may do the job for me. Unfortunately, it seems it is not. I also did not understand how to test wether a path given is absolute or not.
Any ideas?
Actually I was quite misguided first but now found the solution myself. When "base" holds the path A, and filename holds B:
boost::filesystem::path basepath(base), filepath(filename);
if (!basepath.is_complete())
basepath = filepath.remove_leaf() /= basepath;
base = basepath.string();
It works with Linux at least (where it would be very easy to do without boost, but oh well..), still have to test with Windows.
I have this code,
showmessage('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID);
if removedir('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID) then
showmessage('Removed')
else
showmessage('Failed');
The message shows C:\TEMP\0 and this directory does exist as the program created it earlier and used files inside it and then later deletes them. I can see the files and directories so I know they're there. The program successfully deletes the files but does not remove the directory.
If I hardcode the directory it works - this means that it accepts the string
C:\TEMP\0 but does not accept C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID both equate to C:\TEMP\0. I cannot hardcode these directories, so what can I do? How do I convert from a string + string to whatever removedir() is expecting. I looked this up at Delphi basics and it's expecting a string.
I'm confused, since string + string = string. What is going on?
Make sure that neither your program nor any other program have the directory as their current working directory. When you recompile the program this may no longer be the case, so it may be a red herring that the hardcoded value works for you.
In addition to the other good answers, you should not be storing your temp folder in C:\TEMP. Use the value returned from GetTempFilename, instead. Unlike C:\TEMP, this location (which varies by operating system) will work on all operating systems, and all levels of user access control. This also eliminates the risk that the location you have hardcoded might also be hardcoded into another system.
If I understood correctly, openfiles[openfilelist.ItemIndex].ID is a string that contains number?
If so, did you check that it does not contain blanks? Something like this:
filename := 'C:\TEMP\' + trim(openfiles[openfilelist.ItemIndex].ID);
showmessage(filename);
if removedir(filename) then
showmessage('Removed')
else
showmessage('Failed');
What type of objects are openfiles and openfilelist?
Do they open folders at all, if so they may still be open when your trying to delete the folder.