Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
dart::bin::Directory Class Reference

#include <directory.h>

Public Types

enum  ExistsResult { UNKNOWN , EXISTS , DOES_NOT_EXIST }
 

Static Public Member Functions

static void List (DirectoryListing *listing)
 
static ExistsResult Exists (Namespace *namespc, const char *path)
 
static char * CurrentNoScope ()
 
static const char * Current (Namespace *namespc)
 
static const char * SystemTemp (Namespace *namespc)
 
static const char * CreateTemp (Namespace *namespc, const char *path)
 
static void SetSystemTemp (const char *path)
 
static bool SetCurrent (Namespace *namespc, const char *path)
 
static bool Create (Namespace *namespc, const char *path)
 
static bool Delete (Namespace *namespc, const char *path, bool recursive)
 
static bool Rename (Namespace *namespc, const char *path, const char *new_path)
 
static CObjectCreateRequest (const CObjectArray &request)
 
static CObjectDeleteRequest (const CObjectArray &request)
 
static CObjectExistsRequest (const CObjectArray &request)
 
static CObjectCreateTempRequest (const CObjectArray &request)
 
static CObjectCreateSystemTempRequest (const CObjectArray &request)
 
static CObjectListStartRequest (const CObjectArray &request)
 
static CObjectListNextRequest (const CObjectArray &request)
 
static CObjectListStopRequest (const CObjectArray &request)
 
static CObjectRenameRequest (const CObjectArray &request)
 

Detailed Description

Definition at line 240 of file directory.h.

Member Enumeration Documentation

◆ ExistsResult

Enumerator
UNKNOWN 
EXISTS 
DOES_NOT_EXIST 

Definition at line 242 of file directory.h.

Member Function Documentation

◆ Create()

static bool dart::bin::Directory::Create ( Namespace namespc,
const char *  path 
)
static

◆ CreateRequest()

CObject * dart::bin::Directory::CreateRequest ( const CObjectArray request)
static

Definition at line 202 of file directory.cc.

202 {
203 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
205 }
206 Namespace* namespc = CObjectToNamespacePointer(request[0]);
207 RefCntReleaseScope<Namespace> rs(namespc);
208 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
210 }
211 CObjectUint8Array path(request[1]);
212 return Directory::Create(namespc,
213 reinterpret_cast<const char*>(path.Buffer()))
214 ? CObject::True()
215 : CObject::NewOSError();
216}
static CObject * IllegalArgumentError()
static CObject * True()
Definition dartutils.cc:889
static bool Create(Namespace *namespc, const char *path)
static Namespace * CObjectToNamespacePointer(CObject *cobject)
Definition directory.cc:197
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ CreateSystemTempRequest()

static CObject * dart::bin::Directory::CreateSystemTempRequest ( const CObjectArray request)
static

◆ CreateTemp()

static const char * dart::bin::Directory::CreateTemp ( Namespace namespc,
const char *  path 
)
static

◆ CreateTempRequest()

CObject * dart::bin::Directory::CreateTempRequest ( const CObjectArray request)
static

Definition at line 260 of file directory.cc.

260 {
261 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
263 }
264 Namespace* namespc = CObjectToNamespacePointer(request[0]);
265 RefCntReleaseScope<Namespace> rs(namespc);
266 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
268 }
269 CObjectUint8Array path(request[1]);
270 const char* result = Directory::CreateTemp(
271 namespc, reinterpret_cast<const char*>(path.Buffer()));
272 if (result == nullptr) {
273 return CObject::NewOSError();
274 }
275 return new CObjectString(CObject::NewString(result));
276}
static Dart_CObject * NewString(const char *str)
Definition dartutils.cc:933
static CObject * NewOSError()
static const char * CreateTemp(Namespace *namespc, const char *path)
GAsyncResult * result

◆ Current()

const char * dart::bin::Directory::Current ( Namespace namespc)
static

Definition at line 558 of file directory.cc.

558 {
559 return Namespace::GetCurrent(namespc);
560}
static const char * GetCurrent(Namespace *namespc)

◆ CurrentNoScope()

static char * dart::bin::Directory::CurrentNoScope ( )
static

◆ Delete()

static bool dart::bin::Directory::Delete ( Namespace namespc,
const char *  path,
bool  recursive 
)
static

◆ DeleteRequest()

CObject * dart::bin::Directory::DeleteRequest ( const CObjectArray request)
static

Definition at line 218 of file directory.cc.

218 {
219 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
221 }
222 Namespace* namespc = CObjectToNamespacePointer(request[0]);
223 RefCntReleaseScope<Namespace> rs(namespc);
224 if ((request.Length() != 3) || !request[1]->IsUint8Array() ||
225 !request[2]->IsBool()) {
227 }
228 CObjectUint8Array path(request[1]);
229 CObjectBool recursive(request[2]);
230 return Directory::Delete(namespc,
231 reinterpret_cast<const char*>(path.Buffer()),
232 recursive.Value())
233 ? CObject::True()
234 : CObject::NewOSError();
235}
static bool Delete(Namespace *namespc, const char *path, bool recursive)

◆ Exists()

static ExistsResult dart::bin::Directory::Exists ( Namespace namespc,
const char *  path 
)
static

◆ ExistsRequest()

CObject * dart::bin::Directory::ExistsRequest ( const CObjectArray request)
static

Definition at line 237 of file directory.cc.

237 {
238 const int kExists = 1;
239 const int kDoesNotExist = 0;
240 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
242 }
243 Namespace* namespc = CObjectToNamespacePointer(request[0]);
244 RefCntReleaseScope<Namespace> rs(namespc);
245 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
247 }
248 CObjectUint8Array path(request[1]);
250 Directory::Exists(namespc, reinterpret_cast<const char*>(path.Buffer()));
251 if (result == Directory::EXISTS) {
252 return new CObjectInt32(CObject::NewInt32(kExists));
253 } else if (result == Directory::DOES_NOT_EXIST) {
254 return new CObjectInt32(CObject::NewInt32(kDoesNotExist));
255 } else {
256 return CObject::NewOSError();
257 }
258}
static Dart_CObject * NewInt32(int32_t value)
Definition dartutils.cc:908
static ExistsResult Exists(Namespace *namespc, const char *path)

◆ List()

void dart::bin::Directory::List ( DirectoryListing listing)
static

Definition at line 548 of file directory.cc.

548 {
549 if (listing->error()) {
550 listing->HandleError();
551 listing->HandleDone();
552 } else {
553 while (ListNext(listing)) {
554 }
555 }
556}
static bool ListNext(DirectoryListing *listing)
Definition directory.cc:516

◆ ListNextRequest()

CObject * dart::bin::Directory::ListNextRequest ( const CObjectArray request)
static

Definition at line 320 of file directory.cc.

320 {
321 if ((request.Length() != 1) || !request[0]->IsIntptr()) {
323 }
324 CObjectIntptr ptr(request[0]);
325 AsyncDirectoryListing* dir_listing =
326 reinterpret_cast<AsyncDirectoryListing*>(ptr.Value());
327 RefCntReleaseScope<AsyncDirectoryListing> rs(dir_listing);
328 if (dir_listing->IsEmpty()) {
329 return new CObjectArray(CObject::NewArray(0));
330 }
331 const int kArraySize = 128;
332 CObjectArray* response = new CObjectArray(CObject::NewArray(kArraySize));
333 dir_listing->SetArray(response, kArraySize);
334 Directory::List(dir_listing);
335 // In case the listing ended before it hit the buffer length, we need to
336 // override the array length.
337 response->AsApiCObject()->value.as_array.length = dir_listing->index();
338 return response;
339}
static const uint32_t kArraySize
static Dart_CObject * NewArray(intptr_t length)
Definition dartutils.cc:942
static void List(DirectoryListing *listing)
Definition directory.cc:548
static CObject * CreateIllegalArgumentError()
Definition directory.cc:278

◆ ListStartRequest()

CObject * dart::bin::Directory::ListStartRequest ( const CObjectArray request)
static

Definition at line 288 of file directory.cc.

288 {
289 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
291 }
292 Namespace* namespc = CObjectToNamespacePointer(request[0]);
293 RefCntReleaseScope<Namespace> rs(namespc);
294 if ((request.Length() != 4) || !request[1]->IsUint8Array() ||
295 !request[2]->IsBool() || !request[3]->IsBool()) {
297 }
298 CObjectUint8Array path(request[1]);
299 CObjectBool recursive(request[2]);
300 CObjectBool follow_links(request[3]);
301 AsyncDirectoryListing* dir_listing = new AsyncDirectoryListing(
302 namespc, reinterpret_cast<const char*>(path.Buffer()), recursive.Value(),
303 follow_links.Value());
304 if (dir_listing->error()) {
305 // Report error now, so we capture the correct OSError.
306 CObject* err = CObject::NewOSError();
307 dir_listing->Release();
308 CObjectArray* error = new CObjectArray(CObject::NewArray(3));
309 error->SetAt(0, new CObjectInt32(
311 error->SetAt(1, request[1]);
312 error->SetAt(2, err);
313 return error;
314 }
315 // TODO(ajohnsen): Consider returning the first few results.
316 return new CObjectIntptr(
317 CObject::NewIntptr(reinterpret_cast<intptr_t>(dir_listing)));
318}
static Dart_CObject * NewIntptr(intptr_t value)
Definition dartutils.cc:920
const uint8_t uint32_t uint32_t GError ** error

◆ ListStopRequest()

CObject * dart::bin::Directory::ListStopRequest ( const CObjectArray request)
static

Definition at line 341 of file directory.cc.

341 {
342 if ((request.Length() != 1) || !request[0]->IsIntptr()) {
344 }
345 CObjectIntptr ptr(request[0]);
346 AsyncDirectoryListing* dir_listing =
347 reinterpret_cast<AsyncDirectoryListing*>(ptr.Value());
348 RefCntReleaseScope<AsyncDirectoryListing> rs(dir_listing);
349
350 // We have retained a reference to the listing here. Therefore the listing's
351 // destructor can't be running. Since no further requests are dispatched by
352 // the Dart code after an async stop call, this PopAll() can't be racing
353 // with any other call on the listing. We don't do an extra Release(), and
354 // we don't delete the weak persistent handle. The file is closed here, but
355 // the memory for the listing will be cleaned up when the finalizer runs.
356 dir_listing->PopAll();
357 return new CObjectBool(CObject::Bool(true));
358}
static CObject * Bool(bool value)
Definition dartutils.cc:897

◆ Rename()

static bool dart::bin::Directory::Rename ( Namespace namespc,
const char *  path,
const char *  new_path 
)
static

◆ RenameRequest()

CObject * dart::bin::Directory::RenameRequest ( const CObjectArray request)
static

Definition at line 360 of file directory.cc.

360 {
361 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
363 }
364 Namespace* namespc = CObjectToNamespacePointer(request[0]);
365 RefCntReleaseScope<Namespace> rs(namespc);
366 if ((request.Length() != 3) || !request[1]->IsUint8Array() ||
367 !request[2]->IsString()) {
369 }
370 CObjectUint8Array path(request[1]);
371 CObjectString new_path(request[2]);
372 return Directory::Rename(namespc,
373 reinterpret_cast<const char*>(path.Buffer()),
374 new_path.CString())
375 ? CObject::True()
376 : CObject::NewOSError();
377}
static bool Rename(Namespace *namespc, const char *path, const char *new_path)

◆ SetCurrent()

bool dart::bin::Directory::SetCurrent ( Namespace namespc,
const char *  path 
)
static

Definition at line 562 of file directory.cc.

562 {
563 return Namespace::SetCurrent(namespc, name);
564}
static bool SetCurrent(Namespace *namespc, const char *path)
const char *const name

◆ SetSystemTemp()

void dart::bin::Directory::SetSystemTemp ( const char *  path)
static

Definition at line 187 of file directory.cc.

187 {
188 if (system_temp_path_override_ != nullptr) {
189 free(system_temp_path_override_);
190 system_temp_path_override_ = nullptr;
191 }
192 if (path != nullptr) {
193 system_temp_path_override_ = Utils::StrDup(path);
194 }
195}
static char * StrDup(const char *s)

◆ SystemTemp()

static const char * dart::bin::Directory::SystemTemp ( Namespace namespc)
static

The documentation for this class was generated from the following files: