OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/directory.h" | 5 #include "bin/directory.h" |
6 | 6 |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 CObjectArray* DirectoryListing::NewResponse(Response type, char* arg) { | 292 CObjectArray* DirectoryListing::NewResponse(Response type, char* arg) { |
293 CObjectArray* response = new CObjectArray(CObject::NewArray(2)); | 293 CObjectArray* response = new CObjectArray(CObject::NewArray(2)); |
294 response->SetAt(0, new CObjectInt32(CObject::NewInt32(type))); | 294 response->SetAt(0, new CObjectInt32(CObject::NewInt32(type))); |
295 response->SetAt(1, new CObjectString(CObject::NewString(arg))); | 295 response->SetAt(1, new CObjectString(CObject::NewString(arg))); |
296 return response; | 296 return response; |
297 } | 297 } |
298 | 298 |
299 | 299 |
300 bool DirectoryListing::HandleDirectory(char* dir_name) { | 300 bool DirectoryListing::HandleDirectory(char* dir_name) { |
301 // TODO(sgjesse): Pass flags to indicate whether directory | |
302 // responses are needed. | |
303 CObjectArray* response = NewResponse(kListDirectory, dir_name); | 301 CObjectArray* response = NewResponse(kListDirectory, dir_name); |
304 return Dart_PostCObject(response_port_, response->AsApiCObject()); | 302 return Dart_PostCObject(response_port_, response->AsApiCObject()); |
305 } | 303 } |
306 | 304 |
307 | 305 |
308 bool DirectoryListing::HandleFile(char* file_name) { | 306 bool DirectoryListing::HandleFile(char* file_name) { |
309 // TODO(sgjesse): Pass flags to indicate whether file | |
310 // responses are needed. | |
311 CObjectArray* response = NewResponse(kListFile, file_name); | 307 CObjectArray* response = NewResponse(kListFile, file_name); |
312 return Dart_PostCObject(response_port_, response->AsApiCObject()); | 308 return Dart_PostCObject(response_port_, response->AsApiCObject()); |
313 } | 309 } |
314 | 310 |
315 | 311 |
316 bool DirectoryListing::HandleError(const char* dir_name) { | 312 bool DirectoryListing::HandleError(const char* dir_name) { |
317 // TODO(sgjesse): Pass flags to indicate whether error | |
318 // responses are needed. | |
319 CObject* err = CObject::NewOSError(); | 313 CObject* err = CObject::NewOSError(); |
320 CObjectArray* response = new CObjectArray(CObject::NewArray(3)); | 314 CObjectArray* response = new CObjectArray(CObject::NewArray(3)); |
321 response->SetAt(0, new CObjectInt32(CObject::NewInt32(kListError))); | 315 response->SetAt(0, new CObjectInt32(CObject::NewInt32(kListError))); |
322 response->SetAt(1, new CObjectString(CObject::NewString(dir_name))); | 316 response->SetAt(1, new CObjectString(CObject::NewString(dir_name))); |
323 response->SetAt(2, err); | 317 response->SetAt(2, err); |
324 return Dart_PostCObject(response_port_, response->AsApiCObject()); | 318 return Dart_PostCObject(response_port_, response->AsApiCObject()); |
325 } | 319 } |
OLD | NEW |