0

I want to turn my package which is a combination of application and lib into a package.

MY SITUATION

App X is just a script.dart file that creates files inside the root of app X.

runs fine!

currently for testing I create a new app APP and copy app X inside the APP/packages folder.

but when I run APP/packages/X/script.dart via darteditor I get

cant open file /package/X/c:/APP/X/script.dart

which is wired since I just right click script.dart and run.. is that a wrong path bug?

additionally I checked what if I run script.dart from inside the APP root folder, and I see that the script will open but as soon as I try to create/write a file with

file.writeAsStringSync(contentString, encoding: Encoding.ASCII);

I get

Breaking on exception: FileException: Cannot open file 'C:\APP' (OS Error: Access is denied.

what is the difference when developing a package and using it as a lib packages in sense of filesystem user rights?

currently my structure is

app/bin/script.dart (scripts executed by user)

app/tool/helperScript.dart (functions called by the script in bin)

future structure will also include

app/lib/lib.dart and

app/lib/src/libHelper.dart

UPDATE Current Workaround In my other question how to test dart pub package someone answered:

as seen here I can use the path option in pubspec file.

so instead of having my app inside the users package folder I would

-create an application package,

-the user adds a path to my app in his pubspec (providing the path in the console)

-user executes my scripts

this workaround fixes my file access issues but since the user application would now have path inside pubspec

1.the user can't deploy his package (without editing his pubspec)

2.the user would have to copy my console app to the server he runs his app on (hmm but I am thinking now, since the local machine is only development, he would have to do the same stuff on his production server anyway) so I guess for the moment I will stick with this approach but

I am still interests in

how to access the absolute app root path from within a lib package

Thank you

ps.

since the current solution is create application package and let the user tell you the path and since the problem has evolved I changed the title from

How to access app root path from inside a combined app/lib package

to

How to create a combined Command-line/Library package

Community
  • 1
  • 1
H.R.
  • 496
  • 4
  • 14
  • is your package a library? does it provide some self contained common functionality to be used by other apps/libraries? Pub packages need to follow a strict layout or dart editor won't allow you to upload them, see [here](http://pub.dartlang.org/doc/package-layout.html). Also I'm not sure what you're trying to do but why would you need to access the root directory? – Daniel Robinson Jul 02 '13 at 08:18
  • also I don't think its a good idea to be writing anything into the package root directory from a third party package. The user wants to download your package to use its functionality in a standardised way i.e. importing it into one of his code files and using the public API you provide, not by having your script run and dump a load of random files in the root of his project. – Daniel Robinson Jul 02 '13 at 08:41
  • Well, whats the value of `file`? – MarioP Jul 02 '13 at 09:11
  • @0xor1 my app is a script that would be used to run while the app is inactive, for development purposed only. the user can add his own files that help structure his app and if I would build the files inside package, they would get deleted sooner or later when install update is hit. these files don't need to be inside the users app once they have there app finished. and it would be mainly helpscipts for the user to execute during deleopment – H.R. Jul 02 '13 at 09:44
  • it would be just practical to be able to add a root folder like /devtools/scrip.dart, so the user has easy access to these scripts. additionally he can add special files that will be used by the tools to generate code. also it seems that from inside the package I have problems accessing the filesystem – H.R. Jul 02 '13 at 09:48
  • @MarioP "value of file is: _File" "value of fileservice is: null" "value of path is c:/APP/script.dart" – H.R. Jul 02 '13 at 09:55
  • well it sounds like what you are making is an app to help in other ppls app development which is cool, but in that case why not make it a standalone console app which users can then download from pub as an application package, then let them run it by passing in a command line argument, perhaps the root directory of their other project they are wanting to use your app to help them on. I'd just make it a console app – Daniel Robinson Jul 02 '13 at 10:59
  • Have you taken a look at this doc: [Package layout conventions](http://pub.dartlang.org/doc/package-layout.html) - it explains where all the files go. It would also help if you add your file structure to the question. – Chris Buckett Jul 02 '13 at 14:55
  • when I read your text I was like oh ok will do that then.. but I just remembered that I am going to add additional functions for the user to use inside his app while running, and I need to have both features in the same package. the script accessing the the root while app if off and the functions just act like normal lib while app is running – H.R. Jul 02 '13 at 15:07
  • @Chris Buckett, yes I know the file thank you. adding structure now – H.R. Jul 02 '13 at 15:17

0 Answers0