Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » difference in IFileSystemAccess.generateFile between Linux and Windows????
difference in IFileSystemAccess.generateFile between Linux and Windows???? [message #1378112] Sat, 24 May 2014 04:50 Go to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
I've transferred (painfully) my Xtext/Xtend DSL project from Windows to Linux.

Now I'm finding that my code generation is working differently.


override void doGenerate(Resource resource, IFileSystemAccess fsa) {
var pkage = "\\com\\holycityaudio\\SpinCAD\\CADBlocks\\"
fsa.generateFile(pkage + resource.className+"CADBlock.java", toCADBlockCode(resource.contents.head as Program))
}

On my Windows systems, this created a package com.holycityaudio.SpinCAD.CADBlocks and created the file resource.className+"CADBlock.java" within that package.

On Linux, it is creating a file with the name:

"\com\holycityaudio\SpinCAD\CADBlocks\"+resource.className+"CADBlock.java"

and putting it in the default package. Well of course the rest of my code doesn't actually like this.

What's going on and how can I fix it?

GW


[Updated on: Sat, 24 May 2014 04:52]

Report message to a moderator

Re: difference in IFileSystemAccess.generateFile between Linux and Windows???? [message #1378130 is a reply to message #1378112] Sat, 24 May 2014 05:05 Go to previous messageGo to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
OK, well as I finally remembered, folder slashes go in a different direction on Linux than Windows. So I had to change this

var pkage = "\\com\\holycityaudio\\SpinCAD\\CADBlocks\\"

to this:

var pkage = "/com/holycityaudio/SpinCAD/CADBlocks/"

Of course, I'd like to find a way to make this OS independent. Any ideas?

[Updated on: Sun, 25 May 2014 14:27]

Report message to a moderator

Re: difference in IFileSystemAccess.generateFile between Linux and Windows???? [message #1378323 is a reply to message #1378130] Sat, 24 May 2014 07:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13512
Registered: July 2009
Senior Member
hi,

using / should work on both windown and linux


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: difference in IFileSystemAccess.generateFile between Linux and Windows???? [message #1381367 is a reply to message #1378323] Sun, 25 May 2014 14:19 Go to previous messageGo to next message
Thomas Fritsch is currently offline Thomas FritschFriend
Messages: 28
Registered: April 2013
Location: Germany
Junior Member
Hi,

you can use
"/com/holycityaudio/SpinCAD/CADBlocks/".replace("/", System.getProperty("file.separator"))

So you are compatible even to old Windows versions, which understood only \ but not yet /
Re: difference in IFileSystemAccess.generateFile between Linux and Windows???? [message #1381384 is a reply to message #1381367] Sun, 25 May 2014 14:26 Go to previous message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
Thanks for the info. I don't think I'm going any further back than Windows 7.
Previous Topic:[SOLVED] Validation errors when trying to launch Eclipse Application
Next Topic:Deploy xtext plugin and install the correct version of xtext automatically in the client
Goto Forum:
  


Current Time: Mon Aug 03 18:11:27 GMT 2020

Powered by FUDForum. Page generated in 0.01869 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top