Commit Graph

111 Commits

Author SHA1 Message Date
John McCutchan aaf37ad035 Landing patch set 7 from https://codereview.chromium.org/1450113003/
Review URL: https://codereview.chromium.org/1466523002 .
2015-11-19 14:18:52 -08:00
John McCutchan 28e416b1f4 Revert "Avoid strerror_r portability issues"
This reverts commit ca81c1732b.
2015-11-17 16:34:25 -08:00
John McCutchan ca81c1732b Avoid strerror_r portability issues
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1450113003 .
2015-11-17 15:23:47 -08:00
Søren Gjesse eaeecf2ed1 Add file modes for opening a file write only
Added two new file modes WRITE_ONLY and WRITE_ONLY_APPEND. The current
file modes WRITE and WRITE_APPEND are kept as the read/write mode with
no change. Kept the same overall handling of create/truncate/append
semantics for the new file modes.

R=ager@google.com, ahe@google.com
BUG=

Review URL: https://codereview.chromium.org//1193653002.
2015-06-18 15:19:26 +02:00
ricow@google.com 5160c6564b Fix mac build, missing ;
TBR=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43069 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-22 11:33:47 +00:00
sgjesse@google.com 3f939748cb Fix issue with Link.target and Link.targetSync failing on some file systems
Don't rely on information from lstat64 for the size of the link target. Get
the actual length from just reading the link target.

BUG=http://dartbug.com/21987
R=kustermann@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43066 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-22 10:27:11 +00:00
sgjesse@google.com 218e366f89 Add support for file locking
This adds support for file locking in dart:io.

BUG=http://dartbug.com/17045
R=kustermann@google.com, lrn@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42733 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-09 13:06:37 +00:00
ajohnsen@google.com 7aed60d005 Show actualy FD for files in Observatory.
BUG=
R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36656 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-27 09:18:43 +00:00
ajohnsen@google.com 3265fb5d09 Make FileStat have millisecond precisions, for linux, mac and android.
BUG=https://code.google.com/p/dart/issues/detail?id=18442
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35520 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-29 11:38:50 +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
iposva@google.com f2a6f1b4b6 Another round of cleanups for http://www.dartbug.com/15922
- Address warnings about 64-bit to 32-bit conversions.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32831 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-19 23:35:55 +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
iposva@google.com 781f737c6a First round of http://dartbug.com/15922:
- Address warnings about 64-bit to 32-bit conversions.
- Remove heap profiler.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31867 260f80e4-7a28-3924-810f-c04153c831b5
2014-01-16 05:05:35 +00:00
johnmccutchan@google.com 919dc2d6eb * Introduce ThreadInterrupter which calls a TLS set callback when thread is interrupted.
* Threads can only register and unregister themselves with ThreadInterrupter.
* Profiler is no longer involved in interrupting threads. It's just a callback and the buffer.
* Profiler operates lock free using an atomic operation to reserve sample in sample buffer.
* Linux, Mac, and Windows done.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31170 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-16 18:52:15 +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
ajohnsen@google.com 8f99537455 Fix large-file support for mac os x.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30404 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-19 12:17:57 +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
cbracken@google.com a6ace331f3 Replaced strerror() calls with threadsafe strerror_r().
Mac/Android use the XSI-compliant definition of strerror_r() which stores the message in the passed-in buffer.

Linux uses the GNU-specific definition of strerror_r() which takes a buffer and returns the message in a char* (which may or may not be the passed-in buffer).

BUG=
R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25943 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-08 20:24:05 +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
whesse@google.com 9c6d3b86e4 dart:io | Make FileStat.stat throw an exception when the file does not exist, or cannot be accessed.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23543 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-03 15:01:02 +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
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
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
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
whesse@google.com 2bc9a79282 Add FileSystemEntity.identical, to test if two file system objects are the same.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20307 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-21 09:44:56 +00:00
whesse@google.com 428b58d01c dart:io | Add Link.targetSync on all platforms.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20195 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-19 11:19:03 +00:00
whesse@google.com 2987d5397d dart:io | Add Link class, as sibling to File and Directory.
BUG=

Committed: https://code.google.com/p/dart/source/detail?r=19772
Reverted: https://code.google.com/p/dart/source/detail?r=19777

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19995 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-14 09:37:44 +00:00
ajohnsen@google.com a30171117c Handle /dev/null on linux, as an closed device.
This will make all devices unsupported by epoll act as an empty source.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19796 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-11 15:16:08 +00:00
whesse@google.com 43c13f4ed4 dart:io | Revert addition of Link class, because it conflicts with a Link class in dart2js.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19777 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-11 11:59:57 +00:00
whesse@google.com 31c6f8d3e5 dart:io | Add Link class, as sibling to File and Directory.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19772 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-11 10:34:52 +00:00
whesse@google.com ec7e4e5100 dart:io | Add FileSystemEntity.typeSync to test for symbolic links.
BUG=dartbug.com/8935

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19608 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-07 11:18:38 +00:00
whesse@google.com 6ef35edef1 dart:io | Rename File.name to File.path.
BUG=dartbug.com/8790

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19144 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 15:26:11 +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
gram@google.com 3601944836 Revised CL for customisable logging (replacing printfs).
Review URL: https://codereview.chromium.org//11312242

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15096 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-19 17:38:15 +00:00
kustermann@google.com d0fe9360a9 Fixed missing O_CLOEXEC in Mac OS
TBR=ager@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14964 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-15 14:13:28 +00:00
kustermann@google.com fb093fd342 Added O_CLOEXEC to the flags parameter of open() calls
To prevent sub-processes from inheriting open file descriptors of
the current process, the O_CLOEXEC flag is necessary.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14963 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-15 13:46:15 +00:00
ager@google.com d166fef422 Remove file name from File C++ structure. It is not used.
Currently, the field is being assigned a string that we
immediately deallocate leaving the field invalid. Since
it is not used we should get rid of it.

R=aprelev@gmail.com,sgjesse@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14188 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-29 12:02:35 +00:00
ager@google.com 52230ca22b Support posting of external data into dart as external uint8 arrays through the Dart API.
The native ports use the snapshot reader to create the dart objects. Added support for reading external arrays from snapshots but no support for writing them. The only way an external array is written to a snapshot is through the api message writer.

This allows dart:io to avoid one copy of data read from files and sockets. This change only contains one use of the new API.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9281 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-02 07:22:32 +00:00
ager@google.com 379695ee2b Implement File.lastModified.
R=sgjesse@google.com,ajohnsen@google.com
BUG=dartbug/2988
TEST=standalone/io/file*

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7945 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-24 13:10:02 +00:00
ager@google.com 2596d556a9 Deal with symbolic links for file and directories on Mac and Linux.
R=sgjesse@google.com
BUG=dartbug.com/2516
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7228 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-02 11:39:21 +00:00
ager@google.com aba2e48950 Support length operation without opening file.
Use fstat instead of multiple seek calls to get length of
opened files.

R=sgjesse@google.com
BUG=dartbug.com/1592
TEST=standalone/io/File*Test

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6459 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-12 11:47:32 +00:00
sgjesse@google.com cdc29b23f0 Add error handling to random access file
Now all both sync and async methods on File and RandomAccessFile
should have correct error handling.

Changed readByte and readByteSync to return -1 instead of
reporting an error when end of file is reached. It seems to make
the most sense.

The amount of boiler-plate code in both the native functions and
native port functions in file.cc is growing. Maybe we should
consider some refactoring, e.g. with a table of the expected
argument types for each native port functions together with known
position of the FILE* argument.

R=ager@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5812 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-26 05:54:49 +00:00
sgjesse@google.com e06beb7f89 Fix Mac OS build
TBR=ager@google.com

BUG=none
TEST=none

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5397 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-13 13:09:24 +00:00
sgjesse@google.com 84836f8c56 Error reporting on File in dart:io
This implements consistent error reporting on all methods on File in dart:io. The async onError method is called with an exception argument which is the same exception as would have been thrown from the corresponding sync method.

The one method on Directory which already did this has been updated as well.

R=ager@google.com

BUG=none
TEST=tests/standalone/src/io/FileTest.dart, tests/standalone/src/io/FileInvalidArgumentsTest.dart

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5396 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-13 13:00:47 +00:00
rice@google.com 0b4c8203fc Allow std{in,out,err} to be a socket
Review URL: http://chromiumcodereview.appspot.com/9617012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5056 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-06 21:36:07 +00:00
ager@google.com 7e4a36278f Implement File.directory() and File.directorySync() to get
containing directory for a file.

BUG=dart:1618
TEST=standalone/FileTest

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4464 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-22 16:18:39 +00:00
sgjesse@google.com b4d571dcdd Handle stdio redirection in standalone VM
The recent change to epoll on Linux and kqueue on Mac OS for getting
notifications from file descriptors caused the redirection of stdin,
stdout and stderr for the stand alone VM to stop working.

On Linux epoll failed when file descriptor 0, 1 or 2 redirected from
or to a file war registered. On Mac OS there was just no events
generated from kqueue.

The streams created for stdio, stdout and stderr is now of the correct
type and for file redirections no longer a socket object holding a
file descriptor for a regular file.

Added testing of stdio redirection using both pipes and files. These
tests are currently skipped on Windows.

Fixed handlin of short socket read when reading the process exit code.

Always close the socket port when not waiting for any events.

R=iposva@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4226 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-14 15:20:27 +00:00
ricow@google.com 7c524e3e3c Change file opening operation to set position at the end of the file when FileMode.APPEND is used.
Additionally, allow File.openOutputStream to take a FileMode enum (only FileMode.WRITE and FileMode.APPEND is allowed).
Review URL: https://chromiumcodereview.appspot.com//9346015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3984 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-07 09:34:12 +00:00
sgjesse@google.com bf67f24098 Move assert.h/assert.cc from runtime/vm to runtime/platform
The purpose of this change is twofold:

1. Source in the bin directory can now use the same assertions as
   source in the vm directory. The ASSERT macro used by the code
   in runtime/bin was just defined to use assert from the standard
   C library.
2. Moving other implementation parts from runtime/vm to
   runtime/platform (e.g. classes Monitor and Mutex) for sharing
   between runtime/bin and runtime/vm will be easier as these
   implementations rely on these assertion macros.

Created two gypi files for the platform directory. One for the
headers and one for the source. The source one is only included
when building the VM library and will be present in libdart.a
when the dart executable is linked.

All the code for asserts is still in the dart namespace.

Also re-arranged the order of includes to be alphabetically in
the files touched.

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

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3335 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-16 12:28:10 +00:00