Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
dart::bin::File Class Reference

#include <file.h>

Inheritance diagram for dart::bin::File:
dart::bin::ReferenceCounted< File >

Public Types

enum  FileOpenMode {
  kRead = 0 , kWrite = 1 , kTruncate = 1 << 2 , kWriteOnly = 1 << 3 ,
  kWriteTruncate = kWrite | kTruncate , kWriteOnlyTruncate = kWriteOnly | kTruncate
}
 
enum  DartFileOpenMode {
  kDartRead = 0 , kDartWrite = 1 , kDartAppend = 2 , kDartWriteOnly = 3 ,
  kDartWriteOnlyAppend = 4
}
 
enum  Type {
  kIsFile = 0 , kIsDirectory = 1 , kIsLink = 2 , kIsSock = 3 ,
  kIsPipe = 4 , kDoesNotExist = 5
}
 
enum  Identical { kIdentical = 0 , kDifferent = 1 , kError = 2 }
 
enum  StdioHandleType {
  kTerminal = 0 , kPipe = 1 , kFile = 2 , kSocket = 3 ,
  kOther = 4 , kTypeError = 5
}
 
enum  FileStat {
  kType = 0 , kCreatedTime = 1 , kModifiedTime = 2 , kAccessedTime = 3 ,
  kMode = 4 , kSize = 5 , kStatSize = 6
}
 
enum  LockType {
  kLockMin = 0 , kLockUnlock = 0 , kLockShared = 1 , kLockExclusive = 2 ,
  kLockBlockingShared = 3 , kLockBlockingExclusive = 4 , kLockMax = 4
}
 
enum  MapType { kReadOnly = 0 , kReadExecute = 1 , kReadWrite = 2 }
 

Public Member Functions

intptr_t GetFD ()
 
MappedMemoryMap (MapType type, int64_t position, int64_t length, void *start=nullptr)
 
int64_t Read (void *buffer, int64_t num_bytes)
 
int64_t Write (const void *buffer, int64_t num_bytes)
 
bool ReadFully (void *buffer, int64_t num_bytes)
 
bool WriteFully (const void *buffer, int64_t num_bytes)
 
bool WriteByte (uint8_t byte)
 
bool Print (const char *format,...) PRINTF_ATTRIBUTE(2
 
bool va_start (args, format)
 
 va_end (args)
 
bool VPrint (const char *format, va_list args)
 
int64_t Length ()
 
int64_t Position ()
 
bool SetPosition (int64_t position)
 
bool Truncate (int64_t length)
 
bool Flush ()
 
bool Lock (LockType lock, int64_t start, int64_t end)
 
bool IsClosed ()
 
void Close ()
 
Dart_FinalizableHandle FinalizableHandle () const
 
void SetFinalizableHandle (Dart_FinalizableHandle handle)
 
void DeleteFinalizableHandle (Dart_Isolate isolate, Dart_Handle strong_ref)
 
- Public Member Functions inherited from dart::bin::ReferenceCounted< File >
 ReferenceCounted ()
 
virtual ~ReferenceCounted ()
 
void Retain ()
 
void Release ()
 

Static Public Member Functions

static FileOpen (Namespace *namespc, const char *path, FileOpenMode mode)
 
static FileOpenUri (Namespace *namespc, const char *uri, FileOpenMode mode)
 
static CStringUniquePtr UriToPath (const char *uri)
 
static FileOpenStdio (int fd)
 
static FileOpenFD (int fd)
 
static bool Exists (Namespace *namespc, const char *path)
 
static bool ExistsUri (Namespace *namespc, const char *uri)
 
static bool Create (Namespace *namespc, const char *path, bool exclusive)
 
static bool CreateLink (Namespace *namespc, const char *path, const char *target)
 
static bool CreatePipe (Namespace *namespc, File **readPipe, File **writePipe)
 
static bool Delete (Namespace *namespc, const char *path)
 
static bool DeleteLink (Namespace *namespc, const char *path)
 
static bool Rename (Namespace *namespc, const char *old_path, const char *new_path)
 
static bool RenameLink (Namespace *namespc, const char *old_path, const char *new_path)
 
static bool Copy (Namespace *namespc, const char *old_path, const char *new_path)
 
static int64_t LengthFromPath (Namespace *namespc, const char *path)
 
static void Stat (Namespace *namespc, const char *path, int64_t *data)
 
static time_t LastModified (Namespace *namespc, const char *path)
 
static bool SetLastModified (Namespace *namespc, const char *path, int64_t millis)
 
static time_t LastAccessed (Namespace *namespc, const char *path)
 
static bool SetLastAccessed (Namespace *namespc, const char *path, int64_t millis)
 
static bool IsAbsolutePath (const char *path)
 
static const char * PathSeparator ()
 
static const char * StringEscapedPathSeparator ()
 
static Type GetType (Namespace *namespc, const char *path, bool follow_links)
 
static Identical AreIdentical (Namespace *namespc_1, const char *file_1, Namespace *namespc_2, const char *file_2)
 
static StdioHandleType GetStdioHandleType (int fd)
 
static const char * LinkTarget (Namespace *namespc, const char *pathname, char *dest=nullptr, int dest_size=0)
 
static const char * GetCanonicalPath (Namespace *namespc, const char *path, char *dest=nullptr, int dest_size=0)
 
static const char * ReadLink (const char *pathname)
 
static intptr_t ReadLinkInto (const char *pathname, char *result, size_t result_size)
 
static intptr_t CleanUnixPath (const char *in, char *out, intptr_t outlen)
 
static FileOpenMode DartModeToFileMode (DartFileOpenMode mode)
 
static CObjectExistsRequest (const CObjectArray &request)
 
static CObjectCreateRequest (const CObjectArray &request)
 
static CObjectCreatePipeRequest (const CObjectArray &request)
 
static CObjectDeleteRequest (const CObjectArray &request)
 
static CObjectRenameRequest (const CObjectArray &request)
 
static CObjectCopyRequest (const CObjectArray &request)
 
static CObjectOpenRequest (const CObjectArray &request)
 
static CObjectResolveSymbolicLinksRequest (const CObjectArray &request)
 
static CObjectCloseRequest (const CObjectArray &request)
 
static CObjectPositionRequest (const CObjectArray &request)
 
static CObjectSetPositionRequest (const CObjectArray &request)
 
static CObjectTruncateRequest (const CObjectArray &request)
 
static CObjectLengthRequest (const CObjectArray &request)
 
static CObjectLengthFromPathRequest (const CObjectArray &request)
 
static CObjectLastModifiedRequest (const CObjectArray &request)
 
static CObjectSetLastModifiedRequest (const CObjectArray &request)
 
static CObjectLastAccessedRequest (const CObjectArray &request)
 
static CObjectSetLastAccessedRequest (const CObjectArray &request)
 
static CObjectFlushRequest (const CObjectArray &request)
 
static CObjectReadByteRequest (const CObjectArray &request)
 
static CObjectWriteByteRequest (const CObjectArray &request)
 
static CObjectReadRequest (const CObjectArray &request)
 
static CObjectReadIntoRequest (const CObjectArray &request)
 
static CObjectWriteFromRequest (const CObjectArray &request)
 
static CObjectCreateLinkRequest (const CObjectArray &request)
 
static CObjectDeleteLinkRequest (const CObjectArray &request)
 
static CObjectRenameLinkRequest (const CObjectArray &request)
 
static CObjectLinkTargetRequest (const CObjectArray &request)
 
static CObjectTypeRequest (const CObjectArray &request)
 
static CObjectIdenticalRequest (const CObjectArray &request)
 
static CObjectStatRequest (const CObjectArray &request)
 
static CObjectLockRequest (const CObjectArray &request)
 

Public Attributes

bool result = VPrint(format, args)
 
return result
 

Friends

class ReferenceCounted< File >
 

Detailed Description

Definition at line 53 of file file.h.

Member Enumeration Documentation

◆ DartFileOpenMode

Enumerator
kDartRead 
kDartWrite 
kDartAppend 
kDartWriteOnly 
kDartWriteOnlyAppend 

Definition at line 67 of file file.h.

67 {
68 kDartRead = 0,
69 kDartWrite = 1,
70 kDartAppend = 2,
73 };
@ kDartWriteOnlyAppend
Definition: file.h:72
@ kDartWrite
Definition: file.h:69
@ kDartWriteOnly
Definition: file.h:71
@ kDartAppend
Definition: file.h:70

◆ FileOpenMode

Enumerator
kRead 
kWrite 
kTruncate 
kWriteOnly 
kWriteTruncate 
kWriteOnlyTruncate 

Definition at line 55 of file file.h.

55 {
56 kRead = 0,
57 kWrite = 1,
58 kTruncate = 1 << 2,
59 kWriteOnly = 1 << 3,
62 };
@ kWriteOnly
Definition: file.h:59
@ kWriteTruncate
Definition: file.h:60
@ kWriteOnlyTruncate
Definition: file.h:61

◆ FileStat

Enumerator
kType 
kCreatedTime 
kModifiedTime 
kAccessedTime 
kMode 
kSize 
kStatSize 

Definition at line 96 of file file.h.

96 {
97 // These match the constants in FileStat in file_system_entity.dart.
98 kType = 0,
99 kCreatedTime = 1,
100 kModifiedTime = 2,
101 kAccessedTime = 3,
102 kMode = 4,
103 kSize = 5,
104 kStatSize = 6
105 };
@ kModifiedTime
Definition: file.h:100
@ kCreatedTime
Definition: file.h:99
@ kAccessedTime
Definition: file.h:101

◆ Identical

Enumerator
kIdentical 
kDifferent 
kError 

Definition at line 84 of file file.h.

84{ kIdentical = 0, kDifferent = 1, kError = 2 };
@ kDifferent
Definition: file.h:84
@ kIdentical
Definition: file.h:84

◆ LockType

Enumerator
kLockMin 
kLockUnlock 
kLockShared 
kLockExclusive 
kLockBlockingShared 
kLockBlockingExclusive 
kLockMax 

Definition at line 107 of file file.h.

107 {
108 // These match the constants in FileStat in file_impl.dart.
109 kLockMin = 0,
110 kLockUnlock = 0,
111 kLockShared = 1,
112 kLockExclusive = 2,
115 kLockMax = 4
116 };
@ kLockBlockingShared
Definition: file.h:113
@ kLockBlockingExclusive
Definition: file.h:114
@ kLockExclusive
Definition: file.h:112

◆ MapType

Enumerator
kReadOnly 
kReadExecute 
kReadWrite 

Definition at line 120 of file file.h.

120 {
121 kReadOnly = 0,
122 kReadExecute = 1,
123 kReadWrite = 2,
124 };
@ kReadExecute
Definition: file.h:122

◆ StdioHandleType

Enumerator
kTerminal 
kPipe 
kFile 
kSocket 
kOther 
kTypeError 

Definition at line 86 of file file.h.

86 {
87 // These match the constants in stdio.dart.
88 kTerminal = 0,
89 kPipe = 1,
90 kFile = 2,
91 kSocket = 3,
92 kOther = 4,
93 kTypeError = 5
94 };
@ kTypeError
Definition: file.h:93

◆ Type

Enumerator
kIsFile 
kIsDirectory 
kIsLink 
kIsSock 
kIsPipe 
kDoesNotExist 

Definition at line 75 of file file.h.

75 {
76 kIsFile = 0,
77 kIsDirectory = 1,
78 kIsLink = 2,
79 kIsSock = 3, // Unix Domain Socket.
80 kIsPipe = 4, // FIFO/Pipe.
82 };
@ kIsDirectory
Definition: file.h:77
@ kDoesNotExist
Definition: file.h:81

Member Function Documentation

◆ AreIdentical()

static Identical dart::bin::File::AreIdentical ( Namespace namespc_1,
const char *  file_1,
Namespace namespc_2,
const char *  file_2 
)
static

◆ CleanUnixPath()

intptr_t dart::bin::File::CleanUnixPath ( const char *  in,
char *  out,
intptr_t  outlen 
)
static

Definition at line 655 of file file.cc.

655 {
656 if (in[0] == 0) {
657 snprintf(out, outlen, ".");
658 return 1;
659 }
660
661 const bool rooted = (in[0] == '/');
662 intptr_t in_index = 0; // Index of the next byte to read.
663 intptr_t out_index = 0; // Index of the next byte to write.
664
665 if (rooted) {
666 out[out_index++] = '/';
667 in_index++;
668 }
669 // The output index at which '..' cannot be cleaned further.
670 intptr_t dotdot = out_index;
671
672 while (in[in_index] != 0) {
673 if (in[in_index] == '/') {
674 // 1. Reduce multiple slashes to a single slash.
675 CHECK_CAN_INCREMENT(in_index);
676 in_index++;
677 } else if ((in[in_index] == '.') && IS_SEPARATOR(in[in_index + 1])) {
678 // 2. Eliminate . path name elements (the current directory).
679 CHECK_CAN_INCREMENT(in_index);
680 in_index++;
681 } else if ((in[in_index] == '.') && (in[in_index + 1] == '.') &&
682 IS_SEPARATOR(in[in_index + 2])) {
683 CHECK_CAN_INCREMENT(in_index + 1);
684 in_index += 2;
685 if (out_index > dotdot) {
686 // 3. Eliminate .. path elements (the parent directory) and the element
687 // that precedes them.
688 out_index--;
689 while ((out_index > dotdot) && (out[out_index] != '/')) {
690 out_index--;
691 }
692 } else if (rooted) {
693 // 4. Eliminate .. elements that begin a rooted path, that is, replace
694 // /.. by / at the beginning of a path.
695 continue;
696 } else if (!rooted) {
697 if (out_index > 0) {
698 out[out_index++] = '/';
699 }
700 // 5. Leave intact .. elements that begin a non-rooted path.
701 out[out_index++] = '.';
702 out[out_index++] = '.';
703 dotdot = out_index;
704 }
705 } else {
706 if ((rooted && out_index != 1) || (!rooted && out_index != 0)) {
707 // Add '/' before normal path component, for non-root components.
708 out[out_index++] = '/';
709 }
710
711 while (!IS_SEPARATOR(in[in_index])) {
712 CHECK_CAN_INCREMENT(in_index);
713 out[out_index++] = in[in_index++];
714 }
715 }
716 }
717
718 if (out_index == 0) {
719 snprintf(out, outlen, ".");
720 return 1;
721 }
722
723 // Append null character.
724 out[out_index] = 0;
725 return out_index;
726}
#define IS_SEPARATOR(c)
Definition: file.cc:646
#define CHECK_CAN_INCREMENT(i)
Definition: file.cc:650

◆ Close()

void dart::bin::File::Close ( )

◆ CloseRequest()

CObject * dart::bin::File::CloseRequest ( const CObjectArray request)
static

Definition at line 901 of file file.cc.

901 {
902 if ((request.Length() != 1) || !request[0]->IsIntptr()) {
903 return new CObjectIntptr(CObject::NewIntptr(-1));
904 }
905 File* file = CObjectToFilePointer(request[0]);
906 RefCntReleaseScope<File> rs(file);
907 // We have retained a reference to the file here. Therefore the file's
908 // destructor can't be running. Since no further requests are dispatched by
909 // the Dart code after an async close call, this Close() can't be racing
910 // with any other call on the file. We don't do an extra Release(), and we
911 // don't delete the weak persistent handle. The file is closed here, but the
912 // memory will be cleaned up when the finalizer runs.
913 ASSERT(!file->IsClosed());
914 file->Close();
915 return new CObjectIntptr(CObject::NewIntptr(0));
916}
static Dart_CObject * NewIntptr(intptr_t value)
Definition: dartutils.cc:914
#define ASSERT(E)
static File * CObjectToFilePointer(CObject *cobject)
Definition: file.cc:741

◆ Copy()

static bool dart::bin::File::Copy ( Namespace namespc,
const char *  old_path,
const char *  new_path 
)
static

◆ CopyRequest()

CObject * dart::bin::File::CopyRequest ( const CObjectArray request)
static

Definition at line 865 of file file.cc.

865 {
866 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
868 }
869 Namespace* namespc = CObjectToNamespacePointer(request[0]);
870 RefCntReleaseScope<Namespace> rs(namespc);
871 if ((request.Length() != 3) || !request[1]->IsUint8Array() ||
872 !request[2]->IsString()) {
874 }
875 CObjectUint8Array old_path(request[1]);
876 CObjectString new_path(request[2]);
877 return File::Copy(namespc, reinterpret_cast<const char*>(old_path.Buffer()),
878 new_path.CString())
879 ? CObject::True()
880 : CObject::NewOSError();
881}
static CObject * IllegalArgumentError()
Definition: dartutils.cc:1026
static CObject * True()
Definition: dartutils.cc:883
static bool Copy(Namespace *namespc, const char *old_path, const char *new_path)
static Namespace * CObjectToNamespacePointer(CObject *cobject)
Definition: directory.cc:197

◆ Create()

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

◆ CreateLink()

static bool dart::bin::File::CreateLink ( Namespace namespc,
const char *  path,
const char *  target 
)
static

◆ CreateLinkRequest()

CObject * dart::bin::File::CreateLinkRequest ( const CObjectArray request)
static

Definition at line 1270 of file file.cc.

1270 {
1271 if ((request.Length() != 3) || !request[0]->IsIntptr()) {
1273 }
1274 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1275 RefCntReleaseScope<Namespace> rs(namespc);
1276 if (!request[1]->IsUint8Array() || !request[2]->IsString()) {
1278 }
1279 CObjectUint8Array link_name(request[1]);
1280 CObjectString target_name(request[2]);
1281 return File::CreateLink(namespc,
1282 reinterpret_cast<const char*>(link_name.Buffer()),
1283 target_name.CString())
1284 ? CObject::True()
1285 : CObject::NewOSError();
1286}
static bool CreateLink(Namespace *namespc, const char *path, const char *target)

◆ CreatePipe()

static bool dart::bin::File::CreatePipe ( Namespace namespc,
File **  readPipe,
File **  writePipe 
)
static

◆ CreatePipeRequest()

CObject * dart::bin::File::CreatePipeRequest ( const CObjectArray request)
static

Definition at line 783 of file file.cc.

783 {
784 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
786 }
787 Namespace* namespc = CObjectToNamespacePointer(request[0]);
788 RefCntReleaseScope<Namespace> rs(namespc);
789
790 File* readPipe;
791 File* writePipe;
792 if (!CreatePipe(namespc, &readPipe, &writePipe)) {
793 return CObject::NewOSError();
794 }
795
796 CObjectArray* pipes = new CObjectArray(CObject::NewArray(2));
797 CObjectNativePointer* readHandle = new CObjectNativePointer(
798 CObject::NewNativePointer(reinterpret_cast<intptr_t>(readPipe),
799 sizeof(*readPipe), ReleaseFile));
800 CObjectNativePointer* writeHandle = new CObjectNativePointer(
801 CObject::NewNativePointer(reinterpret_cast<intptr_t>(writePipe),
802 sizeof(*writePipe), ReleaseFile));
803 pipes->SetAt(0, readHandle);
804 pipes->SetAt(1, writeHandle);
805 return pipes;
806}
static Dart_CObject * NewArray(intptr_t length)
Definition: dartutils.cc:936
static Dart_CObject * NewNativePointer(intptr_t ptr, intptr_t size, Dart_HandleFinalizer callback)
Definition: dartutils.cc:968
static CObject * NewOSError()
Definition: dartutils.cc:1038
static bool CreatePipe(Namespace *namespc, File **readPipe, File **writePipe)
static void ReleaseFile(void *isolate_callback_data, void *peer)
Definition: file.cc:74

◆ CreateRequest()

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

Definition at line 765 of file file.cc.

765 {
766 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
768 }
769 Namespace* namespc = CObjectToNamespacePointer(request[0]);
770 RefCntReleaseScope<Namespace> rs(namespc);
771 if ((request.Length() != 3) || !request[1]->IsUint8Array() ||
772 !request[2]->IsBool()) {
774 }
775 CObjectUint8Array filename(request[1]);
776 CObjectBool exclusive(request[2]);
777 return File::Create(namespc, reinterpret_cast<const char*>(filename.Buffer()),
778 exclusive.Value())
779 ? CObject::True()
780 : CObject::NewOSError();
781}
static bool Create(Namespace *namespc, const char *path, bool exclusive)

◆ DartModeToFileMode()

File::FileOpenMode dart::bin::File::DartModeToFileMode ( DartFileOpenMode  mode)
static

Definition at line 89 of file file_support.cc.

89 {
93 if (mode == File::kDartWrite) {
95 }
96 if (mode == File::kDartAppend) {
97 return File::kWrite;
98 }
101 }
103 return File::kWriteOnly;
104 }
105 return File::kRead;
106}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ Delete()

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

◆ DeleteFinalizableHandle()

void dart::bin::File::DeleteFinalizableHandle ( Dart_Isolate  isolate,
Dart_Handle  strong_ref 
)
inline

Definition at line 216 of file file.h.

216 {
217 Dart_DeleteFinalizableHandle(finalizable_handle_, strong_ref);
218 finalizable_handle_ = nullptr;
219 }
DART_EXPORT void Dart_DeleteFinalizableHandle(Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object)

◆ DeleteLink()

static bool dart::bin::File::DeleteLink ( Namespace namespc,
const char *  path 
)
static

◆ DeleteLinkRequest()

CObject * dart::bin::File::DeleteLinkRequest ( const CObjectArray request)
static

Definition at line 1288 of file file.cc.

1288 {
1289 if ((request.Length() != 2) || !request[0]->IsIntptr()) {
1291 }
1292 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1293 RefCntReleaseScope<Namespace> rs(namespc);
1294 if (!request[1]->IsUint8Array()) {
1296 }
1297 CObjectUint8Array link_path(request[1]);
1298 return File::DeleteLink(namespc,
1299 reinterpret_cast<const char*>(link_path.Buffer()))
1300 ? CObject::True()
1301 : CObject::NewOSError();
1302}
static bool DeleteLink(Namespace *namespc, const char *path)

◆ DeleteRequest()

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

Definition at line 832 of file file.cc.

832 {
833 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
834 return CObject::False();
835 }
836 Namespace* namespc = CObjectToNamespacePointer(request[0]);
837 RefCntReleaseScope<Namespace> rs(namespc);
838 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
839 return CObject::False();
840 }
841 CObjectUint8Array filename(request[1]);
842 return File::Delete(namespc, reinterpret_cast<const char*>(filename.Buffer()))
843 ? CObject::True()
844 : CObject::NewOSError();
845}
static CObject * False()
Definition: dartutils.cc:887
static bool Delete(Namespace *namespc, const char *path)

◆ Exists()

static bool dart::bin::File::Exists ( Namespace namespc,
const char *  path 
)
static

◆ ExistsRequest()

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

Definition at line 751 of file file.cc.

751 {
752 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
754 }
755 Namespace* namespc = CObjectToNamespacePointer(request[0]);
756 RefCntReleaseScope<Namespace> rs(namespc);
757 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
759 }
760 CObjectUint8Array filename(request[1]);
761 return CObject::Bool(
762 File::Exists(namespc, reinterpret_cast<const char*>(filename.Buffer())));
763}
static CObject * Bool(bool value)
Definition: dartutils.cc:891
static bool Exists(Namespace *namespc, const char *path)

◆ ExistsUri()

static bool dart::bin::File::ExistsUri ( Namespace namespc,
const char *  uri 
)
static

◆ FinalizableHandle()

Dart_FinalizableHandle dart::bin::File::FinalizableHandle ( ) const
inline

Definition at line 203 of file file.h.

203 {
204 return finalizable_handle_;
205 }

◆ Flush()

bool dart::bin::File::Flush ( )

◆ FlushRequest()

CObject * dart::bin::File::FlushRequest ( const CObjectArray request)
static

Definition at line 1077 of file file.cc.

1077 {
1078 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1080 }
1081 File* file = CObjectToFilePointer(request[0]);
1082 RefCntReleaseScope<File> rs(file);
1083 if (file->IsClosed()) {
1084 return CObject::FileClosedError();
1085 }
1086 return file->Flush() ? CObject::True() : CObject::NewOSError();
1087}
static CObject * FileClosedError()
Definition: dartutils.cc:1032

◆ GetCanonicalPath()

static const char * dart::bin::File::GetCanonicalPath ( Namespace namespc,
const char *  path,
char *  dest = nullptr,
int  dest_size = 0 
)
static

◆ GetFD()

intptr_t dart::bin::File::GetFD ( )

◆ GetStdioHandleType()

static StdioHandleType dart::bin::File::GetStdioHandleType ( int  fd)
static

◆ GetType()

static Type dart::bin::File::GetType ( Namespace namespc,
const char *  path,
bool  follow_links 
)
static

◆ IdenticalRequest()

CObject * dart::bin::File::IdenticalRequest ( const CObjectArray request)
static

Definition at line 1357 of file file.cc.

1357 {
1358 if ((request.Length() != 3) || !request[0]->IsIntptr()) {
1360 }
1361 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1362 RefCntReleaseScope<Namespace> rs(namespc);
1363 if (!request[1]->IsString() || !request[2]->IsString()) {
1365 }
1366 CObjectString path1(request[1]);
1367 CObjectString path2(request[2]);
1369 File::AreIdentical(namespc, path1.CString(), namespc, path2.CString());
1370 if (result == File::kError) {
1371 return CObject::NewOSError();
1372 }
1373 return (result == File::kIdentical) ? CObject::True() : CObject::False();
1374}
static SkPath path1()
static SkPath path2()
bool result
Definition: file.h:170
static Identical AreIdentical(Namespace *namespc_1, const char *file_1, Namespace *namespc_2, const char *file_2)

◆ IsAbsolutePath()

static bool dart::bin::File::IsAbsolutePath ( const char *  path)
static

◆ IsClosed()

bool dart::bin::File::IsClosed ( )

◆ LastAccessed()

static time_t dart::bin::File::LastAccessed ( Namespace namespc,
const char *  path 
)
static

◆ LastAccessedRequest()

CObject * dart::bin::File::LastAccessedRequest ( const CObjectArray request)
static

Definition at line 1003 of file file.cc.

1003 {
1004 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1006 }
1007 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1008 RefCntReleaseScope<Namespace> rs(namespc);
1009 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
1011 }
1012 CObjectUint8Array filepath(request[1]);
1013 const int64_t return_value = File::LastAccessed(
1014 namespc, reinterpret_cast<const char*>(filepath.Buffer()));
1015 if (return_value < 0) {
1016 return CObject::NewOSError();
1017 }
1018 return new CObjectIntptr(
1020}
static Dart_CObject * NewInt64(int64_t value)
Definition: dartutils.cc:908
static time_t LastAccessed(Namespace *namespc, const char *path)
constexpr intptr_t kMillisecondsPerSecond
Definition: globals.h:560

◆ LastModified()

static time_t dart::bin::File::LastModified ( Namespace namespc,
const char *  path 
)
static

◆ LastModifiedRequest()

CObject * dart::bin::File::LastModifiedRequest ( const CObjectArray request)
static

Definition at line 1040 of file file.cc.

1040 {
1041 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1043 }
1044 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1045 RefCntReleaseScope<Namespace> rs(namespc);
1046 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
1048 }
1049 CObjectUint8Array filepath(request[1]);
1050 const int64_t return_value = File::LastModified(
1051 namespc, reinterpret_cast<const char*>(filepath.Buffer()));
1052 if (return_value < 0) {
1053 return CObject::NewOSError();
1054 }
1055 return new CObjectIntptr(
1057}
static time_t LastModified(Namespace *namespc, const char *path)

◆ Length()

int64_t dart::bin::File::Length ( )

◆ LengthFromPath()

static int64_t dart::bin::File::LengthFromPath ( Namespace namespc,
const char *  path 
)
static

◆ LengthFromPathRequest()

CObject * dart::bin::File::LengthFromPathRequest ( const CObjectArray request)
static

Definition at line 985 of file file.cc.

985 {
986 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
988 }
989 Namespace* namespc = CObjectToNamespacePointer(request[0]);
990 RefCntReleaseScope<Namespace> rs(namespc);
991 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
993 }
994 CObjectUint8Array filepath(request[1]);
995 const int64_t return_value = File::LengthFromPath(
996 namespc, reinterpret_cast<const char*>(filepath.Buffer()));
997 if (return_value < 0) {
998 return CObject::NewOSError();
999 }
1000 return new CObjectInt64(CObject::NewInt64(return_value));
1001}
static int64_t LengthFromPath(Namespace *namespc, const char *path)

◆ LengthRequest()

CObject * dart::bin::File::LengthRequest ( const CObjectArray request)
static

Definition at line 969 of file file.cc.

969 {
970 if ((request.Length() != 1) || !request[0]->IsIntptr()) {
972 }
973 File* file = CObjectToFilePointer(request[0]);
974 RefCntReleaseScope<File> rs(file);
975 if (file->IsClosed()) {
977 }
978 const int64_t return_value = file->Length();
979 if (return_value < 0) {
980 return CObject::NewOSError();
981 }
982 return new CObjectInt64(CObject::NewInt64(return_value));
983}

◆ LinkTarget()

static const char * dart::bin::File::LinkTarget ( Namespace namespc,
const char *  pathname,
char *  dest = nullptr,
int  dest_size = 0 
)
static

◆ LinkTargetRequest()

CObject * dart::bin::File::LinkTargetRequest ( const CObjectArray request)
static

Definition at line 1322 of file file.cc.

1322 {
1323 if ((request.Length() != 2) || !request[0]->IsIntptr()) {
1325 }
1326 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1327 RefCntReleaseScope<Namespace> rs(namespc);
1328 if (!request[1]->IsUint8Array()) {
1330 }
1331 CObjectUint8Array link_path(request[1]);
1332 const char* target = File::LinkTarget(
1333 namespc, reinterpret_cast<const char*>(link_path.Buffer()));
1334 if (target == nullptr) {
1335 return CObject::NewOSError();
1336 }
1337 return new CObjectString(CObject::NewString(target));
1338}
static Dart_CObject * NewString(const char *str)
Definition: dartutils.cc:927
static const char * LinkTarget(Namespace *namespc, const char *pathname, char *dest=nullptr, int dest_size=0)
uint32_t * target

◆ Lock()

bool dart::bin::File::Lock ( LockType  lock,
int64_t  start,
int64_t  end 
)

◆ LockRequest()

CObject * dart::bin::File::LockRequest ( const CObjectArray request)
static

Definition at line 1401 of file file.cc.

1401 {
1402 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1404 }
1405 File* file = CObjectToFilePointer(request[0]);
1406 RefCntReleaseScope<File> rs(file);
1407 if ((request.Length() != 4) || !request[1]->IsInt32OrInt64() ||
1408 !request[2]->IsInt32OrInt64() || !request[3]->IsInt32OrInt64()) {
1410 }
1411 if (file->IsClosed()) {
1412 return CObject::FileClosedError();
1413 }
1414 const int64_t lock = CObjectInt32OrInt64ToInt64(request[1]);
1415 const int64_t start = CObjectInt32OrInt64ToInt64(request[2]);
1416 const int64_t end = CObjectInt32OrInt64ToInt64(request[3]);
1417 return file->Lock(static_cast<File::LockType>(lock), start, end)
1418 ? CObject::True()
1419 : CObject::NewOSError();
1420}
glong glong end
static int64_t CObjectInt32OrInt64ToInt64(CObject *cobject)
Definition: file.cc:728

◆ Map()

MappedMemory * dart::bin::File::Map ( MapType  type,
int64_t  position,
int64_t  length,
void *  start = nullptr 
)

Maps or copies the file into memory.

'position' and 'length' should be page-aligned.

If 'start' is zero, allocates virtual memory for the mapping. When the returned 'MappedMemory' is destroyed, the mapping is removed.

If 'start' is non-zero, it must point within a suitably sized existing mapping. The returned 'MappedMemory' will not remove the mapping when it is destroyed; rather, the mapping will be removed when the enclosing mapping is removed. This mode is not supported on Fuchsia.

If 'type' is 'kReadWrite', writes to the mapping are not copied back to the file.

'position' + 'length' may be larger than the file size. In this case, the extra memory is zero-filled.

◆ Open()

static File * dart::bin::File::Open ( Namespace namespc,
const char *  path,
FileOpenMode  mode 
)
static

◆ OpenFD()

static File * dart::bin::File::OpenFD ( int  fd)
static

◆ OpenRequest()

CObject * dart::bin::File::OpenRequest ( const CObjectArray request)
static

Definition at line 808 of file file.cc.

808 {
809 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
811 }
812 Namespace* namespc = CObjectToNamespacePointer(request[0]);
813 RefCntReleaseScope<Namespace> rs(namespc);
814 if ((request.Length() != 3) || !request[1]->IsUint8Array() ||
815 !request[2]->IsInt32()) {
817 }
818 CObjectUint8Array filename(request[1]);
819 CObjectInt32 mode(request[2]);
820 File::DartFileOpenMode dart_file_mode =
821 static_cast<File::DartFileOpenMode>(mode.Value());
822 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode);
823 File* file = File::Open(
824 namespc, reinterpret_cast<const char*>(filename.Buffer()), file_mode);
825 if (file == nullptr) {
826 return CObject::NewOSError();
827 }
828 return new CObjectNativePointer(CObject::NewNativePointer(
829 reinterpret_cast<intptr_t>(file), sizeof(*file), ReleaseFile));
830}
DartFileOpenMode
Definition: file.h:67
static File * Open(Namespace *namespc, const char *path, FileOpenMode mode)
static FileOpenMode DartModeToFileMode(DartFileOpenMode mode)
Definition: file_support.cc:89

◆ OpenStdio()

static File * dart::bin::File::OpenStdio ( int  fd)
static

◆ OpenUri()

static File * dart::bin::File::OpenUri ( Namespace namespc,
const char *  uri,
FileOpenMode  mode 
)
static

◆ PathSeparator()

static const char * dart::bin::File::PathSeparator ( )
static

◆ Position()

int64_t dart::bin::File::Position ( )

◆ PositionRequest()

CObject * dart::bin::File::PositionRequest ( const CObjectArray request)
static

Definition at line 918 of file file.cc.

918 {
919 if ((request.Length() != 1) || !request[0]->IsIntptr()) {
921 }
922 File* file = CObjectToFilePointer(request[0]);
923 RefCntReleaseScope<File> rs(file);
924 if (file->IsClosed()) {
926 }
927 const intptr_t return_value = file->Position();
928 if (return_value < 0) {
929 return CObject::NewOSError();
930 }
931 return new CObjectIntptr(CObject::NewIntptr(return_value));
932}

◆ Print()

bool dart::bin::File::Print ( const char *  format,
  ... 
)

◆ Read()

int64_t dart::bin::File::Read ( void *  buffer,
int64_t  num_bytes 
)

◆ ReadByteRequest()

CObject * dart::bin::File::ReadByteRequest ( const CObjectArray request)
static

Definition at line 1089 of file file.cc.

1089 {
1090 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1092 }
1093 File* file = CObjectToFilePointer(request[0]);
1094 RefCntReleaseScope<File> rs(file);
1095 if (file->IsClosed()) {
1096 return CObject::FileClosedError();
1097 }
1098 uint8_t buffer;
1099 const int64_t bytes_read = file->Read(reinterpret_cast<void*>(&buffer), 1);
1100 if (bytes_read < 0) {
1101 return CObject::NewOSError();
1102 }
1103 if (bytes_read == 0) {
1104 return new CObjectIntptr(CObject::NewIntptr(-1));
1105 }
1106 return new CObjectIntptr(CObject::NewIntptr(buffer));
1107}
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ ReadFully()

bool dart::bin::File::ReadFully ( void *  buffer,
int64_t  num_bytes 
)

Definition at line 41 of file file_support.cc.

41 {
42 int64_t remaining = num_bytes;
43 char* current_buffer = reinterpret_cast<char*>(buffer);
44 while (remaining > 0) {
45 int64_t bytes_read = Read(current_buffer, remaining);
46 if (bytes_read <= 0) {
47 return false;
48 }
49 remaining -= bytes_read; // Reduce the number of remaining bytes.
50 current_buffer += bytes_read; // Move the buffer forward.
51 }
52 return true;
53}
int64_t Read(void *buffer, int64_t num_bytes)

◆ ReadIntoRequest()

CObject * dart::bin::File::ReadIntoRequest ( const CObjectArray request)
static

Definition at line 1163 of file file.cc.

1163 {
1164 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1166 }
1167 File* file = CObjectToFilePointer(request[0]);
1168 RefCntReleaseScope<File> rs(file);
1169 if ((request.Length() != 2) || !request[1]->IsInt32OrInt64()) {
1171 }
1172 if (file->IsClosed()) {
1173 return CObject::FileClosedError();
1174 }
1175 const int64_t length = CObjectInt32OrInt64ToInt64(request[1]);
1177 if (io_buffer == nullptr) {
1178 return CObject::NewOSError();
1179 }
1180 uint8_t* data = io_buffer->value.as_external_typed_data.data;
1181 const int64_t bytes_read = file->Read(data, length);
1182 if (bytes_read < 0) {
1183 CObject::FreeIOBufferData(io_buffer);
1184 return CObject::NewOSError();
1185 }
1186
1187 // Possibly shrink the used malloc() storage if the actual number of bytes is
1188 // significantly lower.
1189 CObject::ShrinkIOBuffer(io_buffer, bytes_read);
1190
1191 auto external_array = new CObjectExternalUint8Array(io_buffer);
1192 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1193 result->SetAt(0, new CObjectIntptr(CObject::NewInt32(0)));
1194 result->SetAt(1, new CObjectInt64(CObject::NewInt64(bytes_read)));
1195 result->SetAt(2, external_array);
1196 return result;
1197}
static void FreeIOBufferData(Dart_CObject *object)
Definition: dartutils.cc:1019
static Dart_CObject * NewIOBuffer(int64_t length)
Definition: dartutils.cc:978
static Dart_CObject * NewInt32(int32_t value)
Definition: dartutils.cc:902
static void ShrinkIOBuffer(Dart_CObject *cobject, int64_t new_length)
Definition: dartutils.cc:993
size_t length
static int8_t data[kExtLength]
union _Dart_CObject::@86 value
uint8_t * data
struct _Dart_CObject::@86::@91 as_external_typed_data

◆ ReadLink()

static const char * dart::bin::File::ReadLink ( const char *  pathname)
static

◆ ReadLinkInto()

static intptr_t dart::bin::File::ReadLinkInto ( const char *  pathname,
char *  result,
size_t  result_size 
)
static

◆ ReadRequest()

CObject * dart::bin::File::ReadRequest ( const CObjectArray request)
static

Definition at line 1128 of file file.cc.

1128 {
1129 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1131 }
1132 File* file = CObjectToFilePointer(request[0]);
1133 RefCntReleaseScope<File> rs(file);
1134 if ((request.Length() != 2) || !request[1]->IsInt32OrInt64()) {
1136 }
1137 if (file->IsClosed()) {
1138 return CObject::FileClosedError();
1139 }
1140 const int64_t length = CObjectInt32OrInt64ToInt64(request[1]);
1142 if (io_buffer == nullptr) {
1143 return CObject::NewOSError();
1144 }
1145 uint8_t* data = io_buffer->value.as_external_typed_data.data;
1146 const int64_t bytes_read = file->Read(data, length);
1147 if (bytes_read < 0) {
1148 CObject::FreeIOBufferData(io_buffer);
1149 return CObject::NewOSError();
1150 }
1151
1152 // Possibly shrink the used malloc() storage if the actual number of bytes is
1153 // significantly lower.
1154 CObject::ShrinkIOBuffer(io_buffer, bytes_read);
1155
1156 auto external_array = new CObjectExternalUint8Array(io_buffer);
1157 CObjectArray* result = new CObjectArray(CObject::NewArray(2));
1158 result->SetAt(0, new CObjectIntptr(CObject::NewInt32(0)));
1159 result->SetAt(1, external_array);
1160 return result;
1161}

◆ Rename()

static bool dart::bin::File::Rename ( Namespace namespc,
const char *  old_path,
const char *  new_path 
)
static

◆ RenameLink()

static bool dart::bin::File::RenameLink ( Namespace namespc,
const char *  old_path,
const char *  new_path 
)
static

◆ RenameLinkRequest()

CObject * dart::bin::File::RenameLinkRequest ( const CObjectArray request)
static

Definition at line 1304 of file file.cc.

1304 {
1305 if ((request.Length() != 3) || !request[0]->IsIntptr()) {
1307 }
1308 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1309 RefCntReleaseScope<Namespace> rs(namespc);
1310 if (!request[1]->IsUint8Array() || !request[2]->IsString()) {
1312 }
1313 CObjectUint8Array old_path(request[1]);
1314 CObjectString new_path(request[2]);
1315 return File::RenameLink(namespc,
1316 reinterpret_cast<const char*>(old_path.Buffer()),
1317 new_path.CString())
1318 ? CObject::True()
1319 : CObject::NewOSError();
1320}
static bool RenameLink(Namespace *namespc, const char *old_path, const char *new_path)

◆ RenameRequest()

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

Definition at line 847 of file file.cc.

847 {
848 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
850 }
851 Namespace* namespc = CObjectToNamespacePointer(request[0]);
852 RefCntReleaseScope<Namespace> rs(namespc);
853 if ((request.Length() != 3) || !request[1]->IsUint8Array() ||
854 !request[2]->IsString()) {
856 }
857 CObjectUint8Array old_path(request[1]);
858 CObjectString new_path(request[2]);
859 return File::Rename(namespc, reinterpret_cast<const char*>(old_path.Buffer()),
860 new_path.CString())
861 ? CObject::True()
862 : CObject::NewOSError();
863}
static bool Rename(Namespace *namespc, const char *old_path, const char *new_path)

◆ ResolveSymbolicLinksRequest()

CObject * dart::bin::File::ResolveSymbolicLinksRequest ( const CObjectArray request)
static

Definition at line 883 of file file.cc.

883 {
884 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
886 }
887 Namespace* namespc = CObjectToNamespacePointer(request[0]);
888 RefCntReleaseScope<Namespace> rs(namespc);
889 if ((request.Length() != 2) || !request[1]->IsUint8Array()) {
891 }
892 CObjectUint8Array filename(request[1]);
893 const char* result = File::GetCanonicalPath(
894 namespc, reinterpret_cast<const char*>(filename.Buffer()));
895 if (result == nullptr) {
896 return CObject::NewOSError();
897 }
898 return new CObjectString(CObject::NewString(result));
899}
static const char * GetCanonicalPath(Namespace *namespc, const char *path, char *dest=nullptr, int dest_size=0)

◆ SetFinalizableHandle()

void dart::bin::File::SetFinalizableHandle ( Dart_FinalizableHandle  handle)
inline

Definition at line 208 of file file.h.

208 {
209 ASSERT(finalizable_handle_ == nullptr);
210 finalizable_handle_ = handle;
211 }

◆ SetLastAccessed()

static bool dart::bin::File::SetLastAccessed ( Namespace namespc,
const char *  path,
int64_t  millis 
)
static

◆ SetLastAccessedRequest()

CObject * dart::bin::File::SetLastAccessedRequest ( const CObjectArray request)
static

Definition at line 1022 of file file.cc.

1022 {
1023 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1025 }
1026 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1027 RefCntReleaseScope<Namespace> rs(namespc);
1028 if ((request.Length() != 3) || !request[1]->IsUint8Array() ||
1029 !request[2]->IsInt32OrInt64()) {
1031 }
1032 CObjectUint8Array filepath(request[1]);
1033 const int64_t millis = CObjectInt32OrInt64ToInt64(request[2]);
1034 return File::SetLastAccessed(
1035 namespc, reinterpret_cast<const char*>(filepath.Buffer()), millis)
1036 ? CObject::Null()
1037 : CObject::NewOSError();
1038}
static CObject * Null()
Definition: dartutils.cc:879
static bool SetLastAccessed(Namespace *namespc, const char *path, int64_t millis)

◆ SetLastModified()

static bool dart::bin::File::SetLastModified ( Namespace namespc,
const char *  path,
int64_t  millis 
)
static

◆ SetLastModifiedRequest()

CObject * dart::bin::File::SetLastModifiedRequest ( const CObjectArray request)
static

Definition at line 1059 of file file.cc.

1059 {
1060 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1062 }
1063 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1064 RefCntReleaseScope<Namespace> rs(namespc);
1065 if ((request.Length() != 3) || !request[1]->IsUint8Array() ||
1066 !request[2]->IsInt32OrInt64()) {
1068 }
1069 CObjectUint8Array filepath(request[1]);
1070 const int64_t millis = CObjectInt32OrInt64ToInt64(request[2]);
1071 return File::SetLastModified(
1072 namespc, reinterpret_cast<const char*>(filepath.Buffer()), millis)
1073 ? CObject::Null()
1074 : CObject::NewOSError();
1075}
static bool SetLastModified(Namespace *namespc, const char *path, int64_t millis)

◆ SetPosition()

bool dart::bin::File::SetPosition ( int64_t  position)

◆ SetPositionRequest()

CObject * dart::bin::File::SetPositionRequest ( const CObjectArray request)
static

Definition at line 934 of file file.cc.

934 {
935 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
937 }
938 File* file = CObjectToFilePointer(request[0]);
939 RefCntReleaseScope<File> rs(file);
940 if ((request.Length() != 2) || !request[1]->IsInt32OrInt64()) {
942 }
943 if (file->IsClosed()) {
945 }
946 const int64_t position = CObjectInt32OrInt64ToInt64(request[1]);
947 return file->SetPosition(position) ? CObject::True() : CObject::NewOSError();
948}

◆ Stat()

static void dart::bin::File::Stat ( Namespace namespc,
const char *  path,
int64_t *  data 
)
static

◆ StatRequest()

CObject * dart::bin::File::StatRequest ( const CObjectArray request)
static

Definition at line 1376 of file file.cc.

1376 {
1377 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1379 }
1380 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1381 RefCntReleaseScope<Namespace> rs(namespc);
1382 if ((request.Length() != 2) || !request[1]->IsString()) {
1384 }
1385 int64_t data[File::kStatSize];
1386 CObjectString path(request[1]);
1387 File::Stat(namespc, path.CString(), data);
1389 return CObject::NewOSError();
1390 }
1391 CObjectArray* result = new CObjectArray(CObject::NewArray(File::kStatSize));
1392 for (int i = 0; i < File::kStatSize; ++i) {
1393 result->SetAt(i, new CObjectInt64(CObject::NewInt64(data[i])));
1394 }
1395 CObjectArray* wrapper = new CObjectArray(CObject::NewArray(2));
1396 wrapper->SetAt(0, new CObjectInt32(CObject::NewInt32(CObject::kSuccess)));
1397 wrapper->SetAt(1, result);
1398 return wrapper;
1399}
static constexpr int kSuccess
Definition: dartutils.h:332
static void Stat(Namespace *namespc, const char *path, int64_t *data)
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

◆ StringEscapedPathSeparator()

static const char * dart::bin::File::StringEscapedPathSeparator ( )
static

◆ Truncate()

bool dart::bin::File::Truncate ( int64_t  length)

◆ TruncateRequest()

CObject * dart::bin::File::TruncateRequest ( const CObjectArray request)
static

Definition at line 950 of file file.cc.

950 {
951 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
953 }
954 File* file = CObjectToFilePointer(request[0]);
955 RefCntReleaseScope<File> rs(file);
956 if ((request.Length() != 2) || !request[1]->IsInt32OrInt64()) {
958 }
959 if (file->IsClosed()) {
961 }
962 const int64_t length = CObjectInt32OrInt64ToInt64(request[1]);
963 if (file->Truncate(length)) {
964 return CObject::True();
965 }
966 return CObject::NewOSError();
967}

◆ TypeRequest()

CObject * dart::bin::File::TypeRequest ( const CObjectArray request)
static

Definition at line 1340 of file file.cc.

1340 {
1341 if ((request.Length() != 3) || !request[0]->IsIntptr()) {
1343 }
1344 Namespace* namespc = CObjectToNamespacePointer(request[0]);
1345 RefCntReleaseScope<Namespace> rs(namespc);
1346 if (!request[1]->IsUint8Array() || !request[2]->IsBool()) {
1348 }
1349 CObjectUint8Array path(request[1]);
1350 CObjectBool follow_links(request[2]);
1352 File::GetType(namespc, reinterpret_cast<const char*>(path.Buffer()),
1353 follow_links.Value());
1354 return new CObjectInt32(CObject::NewInt32(type));
1355}
GLenum type
static Type GetType(Namespace *namespc, const char *path, bool follow_links)

◆ UriToPath()

static CStringUniquePtr dart::bin::File::UriToPath ( const char *  uri)
static

◆ va_end()

dart::bin::File::va_end ( args  )

◆ va_start()

bool dart::bin::File::va_start ( args  ,
format   
)

◆ VPrint()

bool dart::bin::File::VPrint ( const char *  format,
va_list  args 
)

◆ Write()

int64_t dart::bin::File::Write ( const void *  buffer,
int64_t  num_bytes 
)

◆ WriteByte()

bool dart::bin::File::WriteByte ( uint8_t  byte)
inline

Definition at line 165 of file file.h.

165{ return WriteFully(&byte, 1); }
bool WriteFully(const void *buffer, int64_t num_bytes)
Definition: file_support.cc:55

◆ WriteByteRequest()

CObject * dart::bin::File::WriteByteRequest ( const CObjectArray request)
static

Definition at line 1109 of file file.cc.

1109 {
1110 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1112 }
1113 File* file = CObjectToFilePointer(request[0]);
1114 RefCntReleaseScope<File> rs(file);
1115 if ((request.Length() != 2) || !request[1]->IsInt32OrInt64()) {
1117 }
1118 if (file->IsClosed()) {
1119 return CObject::FileClosedError();
1120 }
1121 const int64_t byte = CObjectInt32OrInt64ToInt64(request[1]);
1122 uint8_t buffer = static_cast<uint8_t>(byte & 0xff);
1123 return file->WriteFully(reinterpret_cast<void*>(&buffer), 1)
1124 ? new CObjectInt64(CObject::NewInt64(1))
1126}

◆ WriteFromRequest()

CObject * dart::bin::File::WriteFromRequest ( const CObjectArray request)
static

Definition at line 1227 of file file.cc.

1227 {
1228 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1230 }
1231 File* file = CObjectToFilePointer(request[0]);
1232 RefCntReleaseScope<File> rs(file);
1233 if ((request.Length() != 4) ||
1234 (!request[1]->IsTypedData() && !request[1]->IsArray()) ||
1235 !request[2]->IsInt32OrInt64() || !request[3]->IsInt32OrInt64()) {
1237 }
1238 if (file->IsClosed()) {
1239 return CObject::FileClosedError();
1240 }
1241 int64_t start = CObjectInt32OrInt64ToInt64(request[2]);
1242 int64_t end = CObjectInt32OrInt64ToInt64(request[3]);
1243 int64_t length = end - start;
1244 const uint8_t* buffer_start;
1245 if (request[1]->IsTypedData()) {
1246 CObjectTypedData typed_data(request[1]);
1247 start = start * SizeInBytes(typed_data.Type());
1248 length = length * SizeInBytes(typed_data.Type());
1249 buffer_start = typed_data.Buffer() + start;
1250 } else {
1251 CObjectArray array(request[1]);
1252 uint8_t* allocated_buffer = Dart_ScopeAllocate(length);
1253 buffer_start = allocated_buffer;
1254 for (int i = 0; i < length; i++) {
1255 if (array[i + start]->IsInt32OrInt64()) {
1256 int64_t value = CObjectInt32OrInt64ToInt64(array[i + start]);
1257 allocated_buffer[i] = static_cast<uint8_t>(value & 0xFF);
1258 } else {
1259 // Unsupported type.
1261 }
1262 }
1263 start = 0;
1264 }
1265 return file->WriteFully(reinterpret_cast<const void*>(buffer_start), length)
1266 ? new CObjectInt64(CObject::NewInt64(length))
1267 : CObject::NewOSError();
1268}
uint8_t value
static int SizeInBytes(Dart_TypedData_Type type)
Definition: file.cc:1199
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)

◆ WriteFully()

bool dart::bin::File::WriteFully ( const void *  buffer,
int64_t  num_bytes 
)

Definition at line 55 of file file_support.cc.

55 {
56 int64_t remaining = num_bytes;
57 const char* current_buffer = reinterpret_cast<const char*>(buffer);
58 while (remaining > 0) {
59 // On Windows, narrowing conversion from int64_t to DWORD will cause
60 // unexpected error.
61 // On MacOS, a single write() with more than kMaxInt32 will have
62 // "invalid argument" error.
63 // Therefore, limit the size for single write.
64 int64_t byte_to_write = remaining > kMaxInt32 ? kMaxInt32 : remaining;
65 int64_t bytes_written = Write(current_buffer, byte_to_write);
66 if (bytes_written < 0) {
67 return false;
68 }
69 remaining -= bytes_written; // Reduce the number of remaining bytes.
70 current_buffer += bytes_written; // Move the buffer forward.
71 }
73 intptr_t fd = GetFD();
74 const char* result = nullptr;
75 if ((fd == STDOUT_FILENO) && capture_stdout) {
77 "Stdout", "WriteEvent", reinterpret_cast<const uint8_t*>(buffer),
78 num_bytes);
79 } else if ((fd == STDERR_FILENO) && capture_stderr) {
81 "Stderr", "WriteEvent", reinterpret_cast<const uint8_t*>(buffer),
82 num_bytes);
83 }
84 ASSERT(result == nullptr);
85 }
86 return true;
87}
intptr_t GetFD()
int64_t Write(const void *buffer, int64_t num_bytes)
static bool capture_stderr
Definition: file_support.cc:23
static bool capture_stdout
Definition: file_support.cc:20
DART_EXPORT char * Dart_ServiceSendDataEvent(const char *stream_id, const char *event_kind, const uint8_t *bytes, intptr_t bytes_length)
constexpr int32_t kMaxInt32
Definition: globals.h:483

Friends And Related Function Documentation

◆ ReferenceCounted< File >

friend class ReferenceCounted< File >
friend

Definition at line 356 of file file.h.

Member Data Documentation

◆ result [1/2]

bool dart::bin::File::result = VPrint(format, args)

Definition at line 170 of file file.h.

◆ result [2/2]

return dart::bin::File::result

Definition at line 172 of file file.h.


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