How to access the source directory in codename one - codenameone

I am currently trying to create a plugin-like library for my company.
I need to check if four directories exist within the project structure. As java.io.File is not available, I am pretty confused on how to check for existance of a file that needs to exist within the project structure?
The concrete use-case.
There will be four directories:
/entities
/converter
/attributes
/caches
Now if the developer uses this library and wants to access all, lets say "Person"-Entities from the server, he should be able to call
RestGet.getAll("Person");
and the library looks in the source directory of the project if there are these Files:
/entities/PersonEntity.java //<-- Stores the actual data
/converter/PersonConverter.java //<-- Converts the JSON answer of the server to the Object
/attributes/PersonAttributes.java //<-- An enum that is used to set the attributes of the object
/caches/PersonCache.java //<-- A simple Cache
How can I do this? I tried with FileSystemStorage, but it only tell me that I should use getAppHome()...

I don't quite understand the usage of the source directory which obviously won't exist on the device where your application is running.
You can get access to files in the root of your SRC directory which get packaged into the JAR using Display.getInstance().getResourceAsStream(...).
The replacement to java.io.File is FileSystemStorage which is covered in the developer guide.

Related

Can't play godot game as a software in pc

I made a game in Godot and exported it in release mode in Desktop as exe file.
But, it also created a .pck file and a highscore.data file.
I want to create it as an installable application and I don't want the highscore file in front.
What can I do? I also want to publish it.
I am new in Godot and this is my first game.
Installers are usually wrappers, aside applications that extract the main app to specific directory. Godot doesn't provide functions to create one. If you really need installer, you can write one or just generate with tools like NSIS, Inno Setup and others...
Separate .pck file can be embeded by enabling "Embed Pck" option in export settings.
Screenshot
I'm not sure what highscore.data file is, but it looks like something creating from code. Use user:// prefix (like user://highscore.data) for file paths to create them in app_userdata directory (more in docs).
So if you use this two options, you will get a single .exe file with game.

Golang not able to see templates in external package

I am attempting to write a reusable package in Go. I'm using a structure similar to that described here but slightly different:
/src/bitbucket.org/EXTERNAL_PROJECT_NAME/EXTERNAL_PACKAGE_NAME/...
/src/INTERNAL_PROJECT_NAME/INTERNAL_PACKAGE_NAME/...
Or should the second line be:
/src/bitbucket.org/INTERNAL_PROJECT_NAME/INTERNAL_PACKAGE_NAME/...
Everything works until I need to access a non-go file that exists in the external package. For example, I have some built in templates that I would like to be available without having to include them in my internal projects templates directory.
To that end, I have a "templates" directory in the external project where I want to house some built-in templates and a "templates" directory in my internal project where custom templates will go. But when I attempt to parse templates from the external project template directory, it can't find them.
So how would I go about indicating that I want to get the templates from the external package directory instead of the internal one? I could adjust the path to something like the following:
../../bitbucket.org/EXTERNAL_PROJECT_NAME/EXTERNAL_PACKAGE_NAME/templates/file.html
but this is obviously very clumsy and depends on individual setup, so that's not going to work. In general, if I want to reference a file in an external package instead of my internal project directory, how would I do this gracefully?
Thanks!
Turns out there is a pretty simple solution. Looks something like the following:
package main
import (
"bitbucket.org/EXTERNAL_PROJECT/EXTERNAL_PACKAGE"
"go/build"
)
func main() {
SrcRoot := "/src"
PackageDir := "/bitbucket.org/EXTERNAL_PROJECT/EXTERNAL_PACKAGE"
InternalTemplateDir := build.Default.GOPATH + SrcRoot + PackageDir + "/templates/"
}
GOROOT here provides us with the path to the directory containing all our go code. From there, I want to reference the templates directory in the package source. With InternalTemplateDir, I now have the base path from which to reference templates within the external package.
For ease of use, I will probably build a template loader that checks for a file on an internal file path first and then checks for the same file in the external package, so that any given template can be overridden by including it internally, but essential templates will all have built in versions as well.
If it's not a Go package (aka bitbucket.org/EXTERNAL_PROJECT_NAME/EXTERNAL_PACKAGE_NAME/file.go) it's not gonna work, your best bet us something like https://github.com/jteeuwen/go-bindata.
But I really think you should rethink your problem and use a different approach to it.

Is there an established way to use configuration files for a deployed MATLAB application?

I am working with a MATLAB project, and would like to be able to configure variables and paths without re-creating the executable (currently done by using MATLAB's built-in deploytool). I realize I can create a simple text file, listing key=value pairs, and read that in during run-time. There doesn't seem to be any built-in support in MATLAB for creating configuration files that follow a standard format.
Are there any standard existing ways to use configuration files for MATLAB-generated executables?
1) Add your resource to the package in DeployTool in the shared resources part
2) Read by using:
fullfile(ctfroot(),'config.txt');
Edit : That is suitable if your configuration is "private", that is the user should not edit it. In this case it is deployed together with your program as a resource. If you want a "public" config for the users, I know of no better way than to do what you offered.

List the files in the directory using gwt-filesystems

I tried to list the files in my local directory as well as to read a file. But was not able to do it. Can any one give me sample code to get the list of files in a directory using gwt-filesystem.
It depends from where you are reading. You can't obviously read from the client due to security issues (any HTML wouldn't let you do that). However, you could obviously read the list of files in a folder from the server side.

Can source server (Debugging Tools for Windows) be used with static library projects?

I can't find a way to use the source server tools from the Debugging Tools for Windows on a static library project,
which is built separately from the solutions actually using that library:
The output of "ssindex.cmd" always displays "zero source files found" for the PDB file generated for the library
(using compiler options /ZI and /Fd).
Running "srctool.exe -r" on this PDB displays nothing, which probably means that the PDB file does not contain any source file information.
Running the same command on the PDB file of a test application which is also build as part of the the same solution
yields a list of all expected source files.
Is there a way to use source indexing for a static library project when it should be built seperately from the solutions using it?
Thanks for any suggestions!
You can use the "/Save" and "/Load" options to store and load source information for a static library, respectively. Using these options allows you to store information for your library and then later import it when indexing a project that links against your library.
When indexing your library solution, you specify the "/Save" flag with a directory in which to store index information about the library's source files. For example (assuming you are using Subversion for source control),
ssindex.cmd /System=SVN /Save=c:\source\libproj\srcinfo /Source=c:\source\libproj /Symbols=c:\source\libproj\Release\*.pdb
When later indexing your project that includes your library, you specify the "/Load" flag with the directory containing the library's source file information. For example,
ssindex.cmd /System=SVN /Load=c:\source\libproj\srcinfo /Source=c:\source\binproj /Symbols=c:\source\binproj\Release\*.pdb
There are two potential issues that may affect your ability to use this technique. First, it appears that some source control providers may not support saving and loading source control information. I know that the Subversion provider does and it looks like the SourceSafe provider does, but I haven't checked any others.
Second, this technique appears to only work for one external static library out-of-the-box. There does not seem to be a way to load information from multiple directories and the scripts currently overwrite the contents of the directory each time you use the "/Save" option. You could probably edit the source control provider module to append to the files in the save directory rather than overwrite them, but I have not tried it.
Also, note as you mentioned above that you only need to do this if your library is being built as part of a separate solution. If the static library is part of the solution you are indexing, its source files will be included if they are in the path specified by the "/Source" option.
It probably means you haven't inputed the correct directories when running "ssindex" so for ssindex you need to have: /source=C:/SourceCode/ /symbols=C:/SourceCode/bin/Debug I'm not sure if the "source" has an upper case S or not but that should be it!
when run svnindex.cmd, it always tell you "zero source files found"
after a painful diggin into svn.pm (the perl module to deal with svn), i found that:
first, svn.pm invokes "svn info -R $SourceRoot" to get all version info of files in $SourceRoot (passed by /source option),
then svn.pm stores all files in a dictionary which using the local file path as key
svnindex.cmd call srctool -r to get all source files info in *.pdb, and use the source file name as a key to query info saved in step2
the problem is:
svn.pm uses relative path, but *.pdb uses absolute path, so you will never find a svn log info for any file, then "zero source files found"
fixup:
change svn.pm line 162:
$LocalFile = lc $1;
to   
$LocalFile = $SourceRoot . "\" . lc $1; #make path absolute

Resources