Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Unified Diff: samples/chat/chat_server_lib.dart

Issue 8399033: First round of changes to the file interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samples/chat/chat_server_lib.dart
diff --git a/samples/chat/chat_server_lib.dart b/samples/chat/chat_server_lib.dart
index 722ec7452f90f1c07f8198da1907c8faeca9f550..0e2003792327706563f6735ee2fc47a01ab14876 100644
--- a/samples/chat/chat_server_lib.dart
+++ b/samples/chat/chat_server_lib.dart
@@ -343,8 +343,9 @@ class IsolatedServer extends Isolate {
if (fileName == null) {
fileName = request.path.substring(1);
}
- File file = new File(fileName, false);
- if (file != null) {
+ File file = new File(fileName);
+ if (file.existsSync()) {
+ file.openSync();
int totalRead = 0;
List<int> buffer = new List<int>(BUFFER_SIZE);
@@ -358,11 +359,11 @@ class IsolatedServer extends Isolate {
if (extension == ".png") { mimeType = "image/png"; }
}
response.setHeader("Content-Type", mimeType);
- response.contentLength = file.length;
+ response.contentLength = file.lengthSync();
void writeFileData() {
- while (totalRead < file.length) {
- var read = file.readList(buffer, 0, BUFFER_SIZE);
+ while (totalRead < file.lengthSync()) {
+ var read = file.readListSync(buffer, 0, BUFFER_SIZE);
totalRead += read;
// Write this buffer and get a callback when it makes sense
@@ -371,7 +372,7 @@ class IsolatedServer extends Isolate {
if (!allWritten) break;
}
- if (totalRead == file.length) {
+ if (totalRead == file.lengthSync()) {
response.writeDone();
}
}

Powered by Google App Engine
This is Rietveld 408576698