023fa46e48
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
58 lines
2.0 KiB
Dart
58 lines
2.0 KiB
Dart
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
interface Directory factory _Directory {
|
|
/**
|
|
* Creates a directory object. The path is either a full path or
|
|
* relative to the directory in which the Dart VM was
|
|
* started. Throws an exception if the path does not specify a
|
|
* directory.
|
|
*/
|
|
Directory.open(String dir);
|
|
|
|
/**
|
|
* Close this [Directory]. Terminates listing operation if one is in
|
|
* progress. Returns a boolean indicating whether the close operation
|
|
* succeeded.
|
|
*/
|
|
bool close();
|
|
|
|
/**
|
|
* List the sub-directories and files of this
|
|
* [Directory]. Optionally recurse into sub-directories. For each
|
|
* file and directory, the file or directory handler is called. When
|
|
* all directories have been listed the done handler is called. If
|
|
* the listing operation is recursive, the directory error handler
|
|
* is called if a subdirectory cannot be opened for listing.
|
|
*/
|
|
void list([bool recursive]);
|
|
|
|
/**
|
|
* Sets the directory handler that is called for all directories
|
|
* during listing operations. The directory handler is called with
|
|
* the full path of the directory.
|
|
*/
|
|
void setDirHandler(void dirHandler(String dir));
|
|
|
|
/**
|
|
* Sets the file handler that is called for all directories during
|
|
* listing operations. The directory handler is called with the full
|
|
* path of the file.
|
|
*/
|
|
void setFileHandler(void fileHandler(String file));
|
|
|
|
/**
|
|
* Set the done handler that is called either when a directory
|
|
* listing is completed or when the close method is called.
|
|
*/
|
|
void setDoneHandler(void doneHandler(bool completed));
|
|
|
|
/**
|
|
* Set the directory error handler that is called for all
|
|
* directories that cannot be opened for listing during recursive
|
|
* listing.
|
|
*/
|
|
void setDirErrorHandler(void errorHandler(String dir));
|
|
}
|