Commit graph

102 commits

Author SHA1 Message Date
ajohnsen@google.com 26ee288501 Fix leaking FD from readAs*Sync and writeAs*Sync.
If open was succesfull but the following read/write failed, we would
fail to close the file. We now intercept the error (as we correctly do
in the async case) and close the file before throwing the error to the
user.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34868 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-09 10:38:32 +00:00
ajohnsen@google.com 402774f9a0 Make File:openRead always have one outstanding read, when invoking callbacks.
This sligly improves latency for reading. Note that pause/resume is less
precise now, but it was never a guarantee exactly _when_ pausing would
take place.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34814 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-08 08:58:13 +00:00
ajohnsen@google.com 364bd9eeea Don't call read, if last read returned less bytes than was being read.
This speeds up File.openRead, especially for small files.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34813 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-08 08:47:51 +00:00
ajohnsen@google.com 1eac45f992 Clean up file writing.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34639 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-02 08:21:55 +00:00
ajohnsen@google.com 45d35b1588 Make non-copying version of BytesBuidler and make file-reads faster.
The non-copying version is internally, as this is always the behaviour
we want, when receiving data from the system.

File-reads are also further improved, by only reading data in chunks, if
initial length is 0. This is a special case where the file can be a
character device. Overall improvement is around a factor of 6.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34589 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-01 10:56:19 +00:00
ajohnsen@google.com a08b282ee8 Use a sync-writing StreamConsumer for stdout/stderr.
This makes stdout.write and stderr.write block, until the write is done.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33645 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-13 11:20:34 +00:00
ajohnsen@google.com 0f52be7f63 Make std* blocking file-descriptors.
This will most likely be a performance regression when piping, that
we'll have to look into in the future (copying data through
    message-passing).

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32715 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-17 10:06:35 +00:00
lrn@google.com a6d4c0b996 Code cleanup (mostly io lib and some http lib).
- Unused function removed,
- Make properties always appear before methods,
- Use dart idioms where possible.

BUG=
R=ajohnsen@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31602 260f80e4-7a28-3924-810f-c04153c831b5
2014-01-08 12:03:11 +00:00
ajohnsen@google.com fe6b63d5e4 Add File.copy(Sync) to dart:io.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31125 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-13 12:04:24 +00:00
johnniwinther@google.com 8541952510 Implement least upper bound.
As a side-effect disallow multiple inheritance with different type arguments.

R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30661 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-26 08:32:08 +00:00
sgjesse@google.com 0aa1345b12 Add optional flush argument to some file methods
BUG=http://dartbug.com/8794

R=whesse@google.com, ajohnsen@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29880 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-05 08:46:50 +00:00
whesse@google.com 1e3b58ade0 dart:io | Add 'recursive' flag to File.create and Link.create.
BUG=dartbug.com/12462
R=ajohnsen@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29563 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-30 16:31:53 +00:00
ajohnsen@google.com 253ad80d88 Don't close the _FileStream until all operations are done.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29541 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-30 13:15:32 +00:00
ajohnsen@google.com 7338c0c409 Fix File.openStream where it sometimes would keep the file open.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29539 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-30 12:38:00 +00:00
lrn@google.com f0a1c922a2 Reapply "Remove @deprecated features."
R=scheglov@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29535 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-30 12:09:15 +00:00
ajohnsen@google.com 09e82e02be Let the stream of File:openRead handle cancel correctly.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29534 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-30 11:44:06 +00:00
ajohnsen@google.com 103eac574c Remove FileException, DirectoryException and LinkException from dart:io and use FileSystemException instaed.
BUG=https://code.google.com/p/dart/issues/detail?id=12461
R=nweiz@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29168 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-24 12:17:20 +00:00
whesse@google.com bfc3d53dc6 dart:io | Add FileSystemEntity.parent, make File.directory call it.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28986 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-22 07:32:06 +00:00
floitsch@google.com 4be547c705 Adapt streams for additional stackTrace argument.
R=lrn@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28511 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-11 12:02:20 +00:00
ajohnsen@google.com 8323221e70 Only allow one async operation on RandomAccessFile at a time.
This is to make sure we never have a race-condition on the same
File*/FD. For a File it should be fine, as each operation will open it's
own FD to work on.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28088 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-01 11:23:32 +00:00
ajohnsen@google.com 7e75589a5d Fix File stream on cancel.
Before we could end up having both an issued read and a close request.
Given the new nature of our io-service, this could lead to a race
condition between the two.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27955 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-26 14:34:15 +00:00
ajohnsen@google.com 3e0a59b920 Clean up IOService implementation to be shared between patched and non-patched code.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27888 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-25 15:53:54 +00:00
ajohnsen@google.com a347038cd7 Merge services into a shared IOService in dart:io, and use a native port.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27883 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-25 15:03:24 +00:00
whesse@google.com 4fc5c84809 Recommit add FileSystemEntity.resolveSymbolicLinks
This was reverted in r27481 because of a failure on the debug Windows VM buildbot.

BUG=dartbug.com/1016

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27612 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-18 12:29:47 +00:00
whesse@google.com 31c85401eb Revert "dart:io | Change File.fullPath to FileSystemEntity.resolveSymbolicLinks."
This reverts commit r27475.

BUG=dartbug.com/1016

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27481 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-13 15:00:26 +00:00
whesse@google.com f9ba5f494d dart:io | Change File.fullPath to FileSystemEntity.resolveSymbolicLinks.
BUG=dartbug.com/1016
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27475 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-13 11:15:12 +00:00
whesse@google.com ca27ddeafe Add FileSystemEntity.absolutePath and .isAbsolute properties.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27467 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-13 08:56:16 +00:00
ajohnsen@google.com b57176ef54 Throw FileExceptions when in File when reading as String and decoding fails.
BUG=https://code.google.com/p/dart/issues/detail?id=13199
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27329 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-10 11:14:31 +00:00
ajohnsen@google.com 47239cb3a2 Move delete/deleteSync up to FileSystemEntity, with a shared documentation.
This also means that FileSystemEntity.delete(recursive: true) now will
delete any object on disk, much like 'rm -r', without the need of
wrapping it in a Directory object.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27196 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-05 14:54:38 +00:00
ajohnsen@google.com 38bae0af02 Add FileSystemWatcher class to dart:io.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27048 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-03 12:43:08 +00:00
floitsch@google.com 35d7140e66 Remove Encoding-enum from dart:io and add interface in dart:convert.
BUG= http://dartbug.com/6284
BUG= http://dartbug.com/7966
R=nweiz@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26632 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-26 10:37:25 +00:00
sgjesse@google.com 38506f9d57 Remove the LineTransformer from dart:io
The LineTransformer has been retired, and is replaced with LineSplitter from dart:convert

R=floitsch@google.com, nweiz@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26419 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-21 07:35:46 +00:00
sgjesse@google.com 353428a918 Remove the Path class from dart:io
The Path class in dart:io has been deprecated for some time
now. It was scheduled to be removed on August 11th, so here it
goes.

dart:io still uses the Path class internally, but now it is
private. I will trim it down to what is actually used in a
follow-up change.

R=ahe@google.com, devoncarew@google.com, whesse@google.com
BUG=http://dartbug.com/11666

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26181 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-15 10:10:53 +00:00
whesse@google.com 48cf6c5ebd Fix some analyzer warnings in dart:io.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26051 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-13 14:11:33 +00:00
sgjesse@google.com f01310ef85 Add argument check to Directory and Link constructors
These matches the argument check in the File constructor.

Minor refactoring of final fields in File and Directory implementations.

BUG=http://dartbug.com/11976

R=whesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25705 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-01 11:32:19 +00:00
ajohnsen@google.com f7d1f50329 Remove _BufferList from dart:io and now use BytesBuilder.
BUG=
R=whesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24941 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-12 10:39:02 +00:00
asiva@google.com 1e0c98714b Make writes consistent across socket and file synchronous/asynchronus writes in terms of truncation semantics (reports an argument error if the list element contains a non byte value).
Remove Common_IsBuiltinList as it is not used anymore

Change synchronous file writes to use Dart_TypedDataAcquireData and
Dart_TypedDataReleaseData since the buffer object is always a Uint8List
instead of the more expensive Dart_ListGetAsBytes.

R=ajohnsen@google.com, iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24620 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-29 18:19:33 +00:00
ajohnsen@google.com f6b8d89968 Add FileException.path and clean up file exceptions.
Now correctly throw ArgumentError and not delayed FileExceptions in case
of invalid arguments.

BUG=https://code.google.com/p/dart/issues/detail?id=3075

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24523 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-27 16:42:32 +00:00
sgjesse@google.com 78e9b8ef87 dart:io | Add rename to Link
R=whesse@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24468 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-26 14:09:29 +00:00
sgjesse@google.com 7ce40aa3a0 dart:io | Add File.rename
R=ajohnsen@google.com
BUG=

Committed: https://code.google.com/p/dart/source/detail?r=24029

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24030 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-14 13:34:54 +00:00
sgjesse@google.com 55709f1f43 Ensure that only byte values are sent by sockets and web sockets
R=ajohnsen@google.com
BUG=http://dartbug.com/11007

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23896 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-12 08:33:16 +00:00
ajohnsen@google.com 5ce3b9ddea Clean up dart:io exceptions.
- Introduce IOException.
- Remove HttpParserException.
- Merge RedirectLimitExceededException and RedirectLoopException into
RedirectException.
- Remove 'IO' from FileIOException, DirectoryIOException, LinkIOException
and SocketIOException.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23848 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-11 13:15:46 +00:00
whesse@google.com 180e054164 dart:io | Add .stat() and .statSync() to FileSystemEntity and subclasses File, Directory, and Link.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23540 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-03 12:41:30 +00:00
lrn@google.com faa7227cec Make new StreamController be async by default.
Change all instances, except some tests, to be sync still.
Rename Multiplex to Broadcast everywhere.

R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23453 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-31 06:07:39 +00:00
sgjesse@google.com 7841206de5 Change File.directory to not do any IO
Removed the File.directory and File.directorySync methods and added a
File.directory getter. The File.directory getter does not do any IO,
but just calculates the directory of the file from the path.

R=whesse@google.com
BUG=http://dartbug.com/9926

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23349 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-29 12:38:27 +00:00
johnniwinther@google.com 71bfc2d935 Type check try statements
BUG=
R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23220 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-27 12:47:28 +00:00
ajohnsen@google.com f06faf4a48 Remove explicit delayed futures in dart:io.
After the change of Completers always being delayed to the next tick,
      this is no longer needed.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22984 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-22 07:23:18 +00:00
ajohnsen@google.com d19cfb48ec Ensure to close file-stream on all errors.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22932 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-21 11:11:49 +00:00
ajohnsen@google.com 919ece9a32 Add 'start' and 'end' optional arguments to File.openRead(). This makes it possible to stream a sub-range of a file.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22922 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-21 09:22:24 +00:00
whesse@google.com fb8471244f dart:io | Add FileSystemEntity.stat() and FileStat class.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22685 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-14 16:26:13 +00:00