Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for chmod #1834

Closed
peter-ahe-google opened this issue Feb 23, 2012 · 6 comments
Closed

API for chmod #1834

peter-ahe-google opened this issue Feb 23, 2012 · 6 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report library-io P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@peter-ahe-google
Copy link
Contributor

I just tried using a Dart script in our build system as an alternative to python, see: https://chromiumcodereview.appspot.com/9454026/

The script dart/utils/dartdoc/build_helper.dart is supposed to write another executable Dart script in the output location. The idea is that just like you can type out/Release_ia32/dart to run the Dart VM, you can type out/Release_ia32/dartdoc to invoke dartdoc.

Unfortunately, there doesn't seem to be a way to make the output file executable from the Dart script.

@madsager
Copy link
Contributor

Added Accepted label.

@madsager
Copy link
Contributor

madsager commented Jun 7, 2012

Added this to the Later milestone.

@sgjesse
Copy link
Contributor

sgjesse commented Feb 27, 2013

Removed Type-Defect label.
Added Type-Enhancement label.

@sgjesse
Copy link
Contributor

sgjesse commented Aug 14, 2013

For now one can use Process.run or Process.runSync to run chmod.

Using Process.run and returning a future:

Future makeExecutable(File file) {
  if (!Platform.isWindows) {
    return Process.run("chmod", ["u+x", file.path]).then((result) {
      if (result.exitCode != 0) throw new Exception(result.stderr);
    });
  }
}

main() {
  File file = new File("script.dart");
  file.exists().then(() {
      if (
) return file.delete();
    }).then(() {
      new File("script.dart").openWrite()
          ..writeln("#!out/ReleaseIA32/dart")
          ..writeln()
          ..writeln("main() {")
          ..writeln(" print('Hello, world!');")
          ..writeln("}")
          ..close()
          .then((
) => makeExecutable(file))
          .then((_) => print("Done"));
    });
}

Using Process.runSync and no return value:

void makeExecutableSync(File file) {
  if (!Platform.isWindows) {
    var result = Process.runSync("chmod", ["u+x", file.path]);
    if (result.exitCode != 0) throw new Exception(result.stderr);
  }
}

main() {
  File file = new File("script.dart");
  file.exists().then(() {
      if (
) return file.delete();
    }).then(() {
      new File("script.dart").openWrite()
          ..writeln("#!out/ReleaseIA32/dart")
          ..writeln()
          ..writeln("main() {")
          ..writeln(" print('Hello, world!');")
          ..writeln("}")
          ..close()
          .then((
) {
              makeExecutableSync(file);
              print("Done");
          });
    });
}


Removed Priority-Medium label.
Added Priority-Low label.

@andersjohnsen
Copy link

Added Duplicate label.
Marked as being merged into #15078.

@kevmoo
Copy link
Member

kevmoo commented May 14, 2014

Removed Area-IO label.
Added Area-Library, Library-IO labels.

@peter-ahe-google peter-ahe-google added Type-Enhancement P3 A lower priority bug or feature request area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io closed-duplicate Closed in favor of an existing report labels May 14, 2014
@peter-ahe-google peter-ahe-google added this to the Later milestone May 14, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report library-io P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants