Commit Graph

44 Commits

Author SHA1 Message Date
Zachary Anderson 732bb45c45 [dart:io] Remove double-close from recursive directory delete
closedir() closes the file descriptor wrapped by the DIR, so we
shouldn't close it again.

R=bkonyi@google.com

Review-Url: https://codereview.chromium.org/3005883002 .
2017-08-30 12:49:05 -07:00
Zachary Anderson d0295c873c [dart:io] Namespaces for file IO
Fuchsia requires the ability to sandbox Isolates w.r.t. file IO.
When a new Isolate starts, Fuchsia will pass the Isolate an object
called a namespace. We can translate the namespace object into a
file descriptor suitable for passing to the *at() family of
POSIX file system calls. The file system calls will then
have visibility only into the specified namespace.

We also plumb Namespaces through on all the other platforms as well to
make the change easier to test and so that in the future we can
implement e.g. per-isolate cwds.

This change adds a new internal class to dart:io called _Namespace,
which is implemented in a patch file. See:

sdk/lib/io/namespace_impl.dart
runtime/bin/namespace_patch.dart

The embedder can set up a non-default namespace by calling
_Namespace._setupNamespace during Isolate setup.

Instances of _Namespace have a native field that holds a pointer
to a native Namespace object. See:

runtime/bin/namespace.h

Calls from e.g. file_impl.dart are now also passed a
_Namespace object. The implementations in e.g. file.cc and
file_linux.cc then extract the namespace, and use it to compute a
file descriptor and path suitable for passing to e.g. openat().

related US-313

R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/3007703002 .
2017-08-30 09:34:36 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Ryan Macnak 877284947b Rename TARGET_OS_* to HOST_OS_*.
Like HOST_ARCH_*, HOST_OS_* describes the OS the VM is running on, which may be different from the OS the VM is generating code for during AOT compilation.

Currently we conflate the two when emitting AOT as assembly, and we get away with it because Flutter only uses assembly for targeting iOS and one can only target iOS from a Mac, but we expect to use assembly for Android as well so native tools can unwind Dart frames.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2750843003 .
2017-03-15 13:11:05 -07:00
Zachary Anderson a919399031 Fix directory existence query error
fixes #28147

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2580133002 .
2016-12-16 20:58:52 -08:00
Zachary Anderson 4b9087f9f5 Handle non-regular files in recursive delete
Fix is similar to the fix for directory listing from last week.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2573143002 .
2016-12-14 12:54:59 -08:00
Zachary Anderson 4f04970a13 Handle non-regular file types in the directory lister
fixes #28015

R=floitsch@google.com

Review URL: https://codereview.chromium.org/2556313002 .
2016-12-08 10:02:04 -08:00
Zachary Anderson 479a97b129 clang-format runtime/bin
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2480793002 .
2016-11-04 12:30:56 -07:00
Steven Sheffey 025b433c00 Updated directory_linux.cc to conform with the deprecation of readdir_r (#27093)
* Updated directory_linux.cc to conform with the deprecation of readdir_r

* Fixes to directory_linux.cc

* Modified error checking to more accurately represent the original code

* Removed redundant check and changed variable names for readability

* Changed variable name in DeleteRecursively for readability

* Modified loop for better error checking

* Simplified loop in DirectoryListingEntry::Next

* Fixed text on a comment

* Added summary of pull request and fixed code style

* Fixed commenting style

* Fixed a comment referencing readdir_r
2016-08-23 07:49:00 -07:00
Zachary Anderson 45661a7091 Cleanup in //runtime/bin
R=iposva@google.com

Review URL: https://codereview.chromium.org/1800863002 .
2016-03-16 10:01:00 -07:00
Zachary Anderson c75a817ee0 Fixes some memory leaks in //runtime/bin
Also some style cleanups.

Decided to fix these leaks by using Dart_ScopeAllocate
instead of malloc and new. Leaks are noted in the CL.

I haven't finished looking over all the code in
//runtime/bin yet, but this CL was getting big.

Review URL: https://codereview.chromium.org/1781883002 .
2016-03-14 11:08:52 -07:00
sgjesse@google.com b90c405572 Remove the assumption that stat64 and lstat64 cannot return EINTR on Linux
BUG=http://dartbug.com/21080
R=ajohnsen@google.com

Review URL: https://codereview.chromium.org//600273004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40671 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-25 07:06:06 +00:00
ajohnsen@google.com df14081452 Make opendir test for EINTR again and make NO_RETRY_EXPECTED check in release mode.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//253413002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35352 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-24 06:38:16 +00:00
ajohnsen@google.com ab53006509 Fix recursive directory deletion, to not leak file descriptors (and pointers).
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//249233002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35310 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-23 12:09:12 +00:00
ajohnsen@google.com 0c157cd31e Move signal_blocker to platform and use it by default in TEMP_FAILURE_RETRY.
BUG=http://code.google.com/p/dart/issues/detail?id=16927
R=johnmccutchan@google.com, sgjesse@google.com

Review URL: https://codereview.chromium.org//165723007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33745 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-17 13:51:11 +00:00
ajohnsen@google.com 754c1d2b2a Fix listing of '' and '/'.
BUG=https://code.google.com/p/dart/issues/detail?id=15966
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//131373002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31652 260f80e4-7a28-3924-810f-c04153c831b5
2014-01-09 10:33:56 +00:00
ajohnsen@google.com 6949b04215 Use ino64_t on linux, to match the output of stat64.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//87623002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30658 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-26 07:41:44 +00:00
ajohnsen@google.com 7fef1ff77a Add support for working with large files on unix systems, in dart:io.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//63363010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30399 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-19 11:38:20 +00:00
ajohnsen@google.com c3a9f33ef8 Fix directory-listing to return a future on cancel.
This also fixes an issue where we would leake FDs/HANDLEs if the listing was interrupted.

Add new pause-resume-cancel test of directory listing.

BUG=https://code.google.com/p/dart/issues/detail?id=10163
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//45833003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29454 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-29 15:04:59 +00:00
whesse@google.com 3c0c99a3b9 Add Directory.systemTemp getter to replace createSystemTemp().
BUG=dartbug.com/12496
R=rnystrom@google.com, sgjesse@google.com

Review URL: https://codereview.chromium.org//25720002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28215 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-03 12:55:30 +00:00
whesse@google.com b221c702a3 dart:io | Add Directory.CreateSystemTemp(template) and change Directory.CreateTemp(template).
BUG=dartbug.com/12496
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//25279003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28097 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-01 15:38:01 +00:00
iposva@google.com 7769854d0d - Do NOT mix malloc/free and new/delete!
R=sgjesse@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org//16929007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24145 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-18 15:44:21 +00:00
ajohnsen@google.com 1b83d3b52e Make Directory.list pull-based, making it possible to pause, resume and cancel directory listing.
BUG=https://code.google.com/p/dart/issues/detail?id=10163,
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//16813006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24074 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-17 07:27:19 +00:00
podivilov@google.com 38be0d45cf Provide a POSIX-compliant implementation of Directory::Current.
R=sgjesse@google.com, whesse@google.com

Review URL: https://codereview.chromium.org//15719002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23024 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-22 16:09:07 +00:00
sgjesse@google.com 2ef54d314a Add the ability to change the working directory
Directory.current have been changed from a factory constructor to a
getter and setter. The getter returns a Direcotry object holding the
current working directory. The setter changes the current working
directory of the Dart process.

R=whesse@google.com

BUG=https://code.google.com/p/dart/issues/detail?id=6316, https://code.google.com/p/dart/issues/detail?id=8893

Review URL: https://codereview.chromium.org//13896034

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22116 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-29 12:43:53 +00:00
smok@google.com ebbc2020a2 Put everything in runtime/bin into '::dart::bin' namespace.
Review URL: https://codereview.chromium.org//14341015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22032 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-25 14:22:30 +00:00
whesse@google.com 7c56d46086 dart:io | Ensure that Directory.list terminates even when symbolic links create loops in the file system.
BUG=

Review URL: https://codereview.chromium.org//13818010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21199 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-10 13:07:08 +00:00
ajohnsen@google.com 1bae12223b Fix recursive directory-deletion of top-level files/links.
BUG=

Review URL: https://codereview.chromium.org//13771010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21060 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-08 11:30:33 +00:00
ajohnsen@google.com e75df511a6 Change how File/Directory/Link .delete works.
Now:
- File.delete works iff path is File or Link.
- Directory.delete works iff path is Directory or Link.
- Link.delete works iff path Link.

This now matches .exists.

BUG=

Review URL: https://codereview.chromium.org//13654002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21045 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-08 07:44:18 +00:00
ajohnsen@google.com 578331c57e Fix directory-listing, directory-deletion and file deletion, when links are involved.
BUG=https://code.google.com/p/dart/issues/detail?id=4928,https://code.google.com/p/dart/issues/detail?id=9278,https://code.google.com/p/dart/issues/detail?id=9504

Review URL: https://codereview.chromium.org//13578003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20929 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-04 17:30:17 +00:00
whesse@google.com d2ea504b60 dart:io | Add "followLinks" optional parameter to Directory.list, let it return Link objects when false.
BUG=dartbug.com/7720

Review URL: https://codereview.chromium.org//12638039

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20370 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-22 09:56:14 +00:00
iposva@google.com 9046a44a37 Prepare for removal of source_filter.gypi:
- Guard OS-dependent source files with #if TARGET_OS_* in a similar
  fashion to the architecture dependent sources.
Review URL: https://codereview.chromium.org//12282051

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18786 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-20 21:17:38 +00:00
whesse@google.com f15afd86b2 dart:io Directory.list: Fix use of snprintf return value to work with both C99, Windows, and pre-C99 versions of snprintf.
BUG=

Review URL: https://codereview.chromium.org//12326007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18754 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-20 13:34:50 +00:00
whesse@google.com 25e5ba7f5f Change Directory.list to use the input path, and not resolve it to a full path.
All paths reported by Directory.list are now extensions of the input path.

The Windows platform equivalent change will be committed in a separate CL.

BUG=

Review URL: https://codereview.chromium.org//12217086

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18739 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-20 09:27:08 +00:00
whesse@google.com 45e351e689 Add string.h header file to directory listing implementations.
BUG=

Review URL: https://codereview.chromium.org//12221086

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18248 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-08 12:21:56 +00:00
whesse@google.com 58e8b94008 Use a PathBuffer class in dart:io directory lister.
This simplifies the code, and avoids buffer overflow errors
by encapsulating snprintf.

BUG=

Review URL: https://codereview.chromium.org//12220034

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18247 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-08 11:58:12 +00:00
whesse@google.com 7f499abb04 Fix race condition in Directory.create.
BUG=https://code.google.com/p/dart/issues/detail?id=7679

Review URL: https://codereview.chromium.org//11794048

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16842 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-09 09:59:14 +00:00
ager@google.com ccced31671 Change Directory.create to not fail on existing directory with that name.
The new semantics is to ensure that a directory with that name
exists. There is no way to reliably guard a create call against
existing directories in an async program.

R=sgjesse@google.com
BUG=

Review URL: https://codereview.chromium.org//11175054

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13933 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-23 09:15:01 +00:00
jackpal@google.com e060b66a3e Add _android files for building DartVM on Android
Split directory_posix -> directory_(android|linux|macos)
  This allows us to cleanly make Android-specific changes to
  directory_android.cc

Copy all _linux files to _android files and edit as needed to account
for the differences between Linux and Android:

 + getcwd(0, NULL) doesn't work on Android, have to emulate
 + Android doesn't have a '/tmp' directory, have to emulate
 + Android doesn't provide mkdtemp(), have to emulate.
 + Small differences in the available system include files.
 + Use pthread_cond_timedwait_monotonic instead of
   pthread_condattr_setclock

Review URL: https://chromiumcodereview.appspot.com//10826233

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10613 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-13 23:06:52 +00:00
ager@google.com 953d2599c1 Add exists, create and delete to directory implementation on Linux and Mac.
All of the directory implementations on Linux and Mac are identical
and uncontroversial. Join the implementations in directory_posix for
now. I will split it into the two files again if it becomes necessary.

BUG=
TEST=

Review URL: http://codereview.chromium.org//8277033

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@432 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-14 12:42:44 +00:00
ager@google.com c53c7097d0 Directory: implement recursive directory listing on Linux and Mac.
R=sgjesse@google.com
BUG=
TEST=

Review URL: http://codereview.chromium.org//8243005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@363 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-12 12:53:39 +00:00
ager@google.com 59135cc57b Clean up directory listing interface.
Remove open and close. A directory instance just holds a string
representing the path to the directory.

R=sgjesse@google.com
BUG=
TEST=

Review URL: http://codereview.chromium.org//8244001

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@362 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-12 10:39:30 +00:00
ager@google.com 023fa46e48 Finish non-recursive synchronous directory listing on Linux and Mac.
Next steps: Testing, Windows support and using isolates to make
listing async.

We should probably change the API to not tie a Directory object
to a given OS directory structure. When spawning an isolate to
perform a listing operation, that will open the directory,
list its contents and close the directory. That way we can
do multiple listing operations with the same Directory object
without having interference.

R=sgjesse@google.com,iposva@google.com
BUG=
TEST=

Review URL: https://chromereviews.googleplex.com/3511020

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-05 14:33:49 +00:00
dgrove@google.com 4c0f559d23 Initial checkin.
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-05 05:20:07 +00:00