Flutter Engine
The Flutter Engine
file.cc
Go to the documentation of this file.
1// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5#include "bin/file.h"
6
7#include <stdio.h>
8
9#include "bin/builtin.h"
10#include "bin/dartutils.h"
11#include "bin/io_buffer.h"
12#include "bin/namespace.h"
13#include "bin/utils.h"
15#include "include/dart_api.h"
17#include "platform/globals.h"
18
19namespace dart {
20namespace bin {
21
22static constexpr int kFileNativeFieldIndex = 0;
23
24#if !defined(PRODUCT)
25static bool IsFile(Dart_Handle file_obj) {
26 Dart_Handle file_type = ThrowIfError(
27 DartUtils::GetDartType("dart:io", "_RandomAccessFileOpsImpl"));
28 bool isinstance = false;
29 ThrowIfError(Dart_ObjectIsType(file_obj, file_type, &isinstance));
30 return isinstance;
31}
32#endif
33
34// The file pointer has been passed into Dart as an intptr_t and it is safe
35// to pull it out of Dart as a 64-bit integer, cast it to an intptr_t and
36// from there to a File pointer.
38 File* file;
40 DEBUG_ASSERT(IsFile(dart_this));
42 dart_this, kFileNativeFieldIndex, reinterpret_cast<intptr_t*>(&file));
44 if (file == nullptr) {
46 DartUtils::NewInternalError("No native peer")));
47 }
48 return file;
49}
50
51static void SetFile(Dart_Handle dart_this, intptr_t file_pointer) {
52 DEBUG_ASSERT(IsFile(dart_this));
54 dart_this, kFileNativeFieldIndex, file_pointer);
56}
57
60 // If the file is already closed, GetFile() will return nullptr.
61 if (file != nullptr) {
62 // Increment file's reference count. File_GetPointer() should only be called
63 // when we are about to send the File* to the IO Service.
64 file->Retain();
65 }
66 intptr_t file_pointer = reinterpret_cast<intptr_t>(file);
67 Dart_SetIntegerReturnValue(args, file_pointer);
68}
69
72}
73
74static void ReleaseFile(void* isolate_callback_data, void* peer) {
75 File* file = reinterpret_cast<File*>(peer);
76 file->Release();
77}
78
81 intptr_t file_pointer = DartUtils::GetNativeIntptrArgument(args, 1);
82 File* file = reinterpret_cast<File*>(file_pointer);
84 dart_this, reinterpret_cast<void*>(file), sizeof(*file), ReleaseFile);
85 file->SetFinalizableHandle(handle);
86 SetFile(dart_this, file_pointer);
87}
88
91 const char* filename = DartUtils::GetNativeTypedDataArgument(args, 1);
93 File::DartFileOpenMode dart_file_mode =
94 static_cast<File::DartFileOpenMode>(mode);
95 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode);
96 // Check that the file exists before opening it only for
97 // reading. This is to prevent the opening of directories as
98 // files. Directories can be opened for reading using the posix
99 // 'open' call.
100 File* file = File::Open(namespc, filename, file_mode);
101 if (file != nullptr) {
102 Dart_SetIntegerReturnValue(args, reinterpret_cast<intptr_t>(file));
103 } else {
105 }
106}
107
110 const char* filename = DartUtils::GetNativeTypedDataArgument(args, 1);
111 bool exists = File::Exists(namespc, filename);
113}
114
116 // TODO(zra): The bots are hitting a crash in this function, so we include
117 // some checks here that are normally only in a Debug build. When the crash
118 // is gone, this can go back to using GetFile and SetFile.
120#if !defined(PRODUCT)
121 if (!IsFile(dart_this)) {
123 "File_Close expects the receiver to be a _RandomAccessFileOpsImpl."));
124 }
125#endif
126 File* file;
128 reinterpret_cast<intptr_t*>(&file)));
129 if (file == nullptr) {
131 return;
132 }
133 file->Close();
134 file->DeleteFinalizableHandle(Dart_CurrentIsolate(), dart_this);
135 file->Release();
136
140}
141
143 File* file = GetFile(args);
144 ASSERT(file != nullptr);
145 uint8_t buffer;
146 int64_t bytes_read = file->Read(reinterpret_cast<void*>(&buffer), 1);
147 if (bytes_read == 1) {
149 } else if (bytes_read == 0) {
151 } else {
153 }
154}
155
157 File* file = GetFile(args);
158 ASSERT(file != nullptr);
159 int64_t byte = 0;
161 uint8_t buffer = static_cast<uint8_t>(byte & 0xff);
162 bool success = file->WriteFully(reinterpret_cast<void*>(&buffer), 1);
163 if (success) {
165 } else {
167 }
168 } else {
169 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
171 }
172}
173
175 File* file = GetFile(args);
176 ASSERT(file != nullptr);
177 Dart_Handle length_object = Dart_GetNativeArgument(args, 1);
178 int64_t length = 0;
179 if (!DartUtils::GetInt64Value(length_object, &length) || (length < 0)) {
180 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
182 return;
183 }
184 uint8_t* buffer = nullptr;
185 Dart_Handle external_array = IOBuffer::Allocate(length, &buffer);
186 if (Dart_IsNull(external_array)) {
187 OSError os_error(-1, "Failed to allocate buffer", OSError::kUnknown);
189 return;
190 }
191 int64_t bytes_read = file->Read(reinterpret_cast<void*>(buffer), length);
192 if (bytes_read < 0) {
194 return;
195 }
196 if (bytes_read < length) {
197 const int kNumArgs = 3;
198 Dart_Handle dart_args[kNumArgs];
199 dart_args[0] = external_array;
200 dart_args[1] = Dart_NewInteger(0);
201 dart_args[2] = Dart_NewInteger(bytes_read);
202 // TODO(sgjesse): Cache the _makeUint8ListView function somewhere.
204 ThrowIfError(io_lib);
205 Dart_Handle array_view =
206 Dart_Invoke(io_lib, DartUtils::NewString("_makeUint8ListView"),
207 kNumArgs, dart_args);
208 Dart_SetReturnValue(args, array_view);
209 } else {
210 Dart_SetReturnValue(args, external_array);
211 }
212}
213
215 File* file = GetFile(args);
216 ASSERT(file != nullptr);
217 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
218 ASSERT(Dart_IsList(buffer_obj));
219 // start and end arguments are checked in Dart code to be
220 // integers and have the property that end <=
221 // list.length. Therefore, it is safe to extract their value as
222 // intptr_t.
225 intptr_t length = end - start;
226 intptr_t array_len = 0;
227 Dart_Handle result = Dart_ListLength(buffer_obj, &array_len);
229 ASSERT(end <= array_len);
230
231 uint8_t* buffer;
232 bool is_byte_data = false;
233
234 if (Dart_IsTypedData(buffer_obj)) {
235 // Avoid a memory copy if the input List<int> is an UInt8List.
236 Dart_TypedData_Type data_type;
237 intptr_t bytes_count;
238 ThrowIfError(Dart_TypedDataAcquireData(buffer_obj, &data_type,
239 reinterpret_cast<void**>(&buffer),
240 &bytes_count));
241 if (data_type == Dart_TypedData_kUint8) {
242 is_byte_data = true;
243 buffer += start;
244 ASSERT(bytes_count == array_len);
245 } else {
247 }
248 }
249
250 if (!is_byte_data) {
252 }
253
254 int64_t bytes_read = file->Read(reinterpret_cast<void*>(buffer), length);
255 if (is_byte_data) {
257 }
258 if (bytes_read >= 0) {
259 if (!is_byte_data) {
260 ThrowIfError(Dart_ListSetAsBytes(buffer_obj, start, buffer, bytes_read));
261 }
262 Dart_SetIntegerReturnValue(args, bytes_read);
263 } else {
265 }
266}
267
269 File* file = GetFile(args);
270 ASSERT(file != nullptr);
271
272 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
273
274 // Offset and length arguments are checked in Dart code to be
275 // integers and have the property that (offset + length) <=
276 // list.length. Therefore, it is safe to extract their value as
277 // intptr_t.
280
281 // The buffer object passed in has to be an Int8List or Uint8List object.
282 // Acquire a direct pointer to the data area of the buffer object.
284 intptr_t length = end - start;
285 intptr_t buffer_len = 0;
286 void* buffer = nullptr;
288 Dart_TypedDataAcquireData(buffer_obj, &type, &buffer, &buffer_len);
290
292 ASSERT(end <= buffer_len);
293 ASSERT(buffer != nullptr);
294
295 // Write all the data out into the file.
296 char* byte_buffer = reinterpret_cast<char*>(buffer);
297 bool success = file->WriteFully(byte_buffer + start, length);
298 OSError os_error; // capture error if any
299
300 // Release the direct pointer acquired above.
302
303 if (!success) {
305 } else {
307 }
308}
309
311 File* file = GetFile(args);
312 ASSERT(file != nullptr);
313 intptr_t return_value = file->Position();
314 if (return_value >= 0) {
315 Dart_SetIntegerReturnValue(args, return_value);
316 } else {
318 }
319}
320
322 File* file = GetFile(args);
323 ASSERT(file != nullptr);
324 int64_t position = 0;
326 if (file->SetPosition(position)) {
328 } else {
330 }
331 } else {
332 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
334 }
335}
336
338 File* file = GetFile(args);
339 ASSERT(file != nullptr);
340 int64_t length = 0;
342 if (file->Truncate(length)) {
344 } else {
346 }
347 } else {
348 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
350 }
351}
352
354 File* file = GetFile(args);
355 ASSERT(file != nullptr);
356 int64_t return_value = file->Length();
357 if (return_value >= 0) {
358 Dart_SetIntegerReturnValue(args, return_value);
359 } else {
361 }
362}
363
367 int64_t return_value = File::LengthFromPath(namespc, path);
368 if (return_value >= 0) {
369 Dart_SetIntegerReturnValue(args, return_value);
370 } else {
372 }
373}
374
377 const char* raw_name = DartUtils::GetNativeTypedDataArgument(args, 1);
378 int64_t return_value = File::LastModified(namespc, raw_name);
379 if (return_value >= 0) {
381 } else {
383 }
384}
385
388 int64_t millis;
391 "The second argument must be a 64-bit int."));
392 }
394 bool result = File::SetLastModified(namespc, name, millis);
395 if (!result) {
397 }
398}
399
403 int64_t return_value = File::LastAccessed(namespc, name);
404 if (return_value >= 0) {
406 } else {
408 }
409}
410
413 int64_t millis;
416 "The second argument must be a 64-bit int."));
417 }
419 bool result = File::SetLastAccessed(namespc, name, millis);
420 if (!result) {
422 }
423}
424
426 File* file = GetFile(args);
427 ASSERT(file != nullptr);
428 if (file->Flush()) {
430 } else {
432 }
433}
434
436 File* file = GetFile(args);
437 ASSERT(file != nullptr);
438 int64_t lock;
439 int64_t start;
440 int64_t end;
444 if ((lock >= File::kLockMin) && (lock <= File::kLockMax) && (start >= 0) &&
445 (end == -1 || end > start)) {
446 if (file->Lock(static_cast<File::LockType>(lock), start, end)) {
448 } else {
450 }
451 return;
452 }
453 }
454 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
456}
457
460 Dart_Handle exclusive_handle = Dart_GetNativeArgument(args, 2);
462 bool exclusive = DartUtils::GetBooleanValue(exclusive_handle);
463 bool result = File::Create(namespc, path, exclusive);
464 if (result) {
466 } else {
468 }
469}
470
475 bool result = File::CreateLink(namespc, name, target);
476 if (!result) {
478 }
479}
480
483
484 File* readPipe;
485 File* writePipe;
486 if (File::CreatePipe(namespc, &readPipe, &writePipe)) {
488 Dart_Handle readHandle =
489 ThrowIfError(Dart_NewInteger(reinterpret_cast<intptr_t>(readPipe)));
490 Dart_Handle writeHandle =
491 ThrowIfError(Dart_NewInteger(reinterpret_cast<intptr_t>(writePipe)));
492 ThrowIfError(Dart_ListSetAt(pipes, 0, readHandle));
493 ThrowIfError(Dart_ListSetAt(pipes, 1, writeHandle));
495 } else {
497 }
498}
499
503 const char* target = File::LinkTarget(namespc, name);
504 if (target == nullptr) {
506 } else {
509 }
510}
511
515 bool result = File::Delete(namespc, path);
516 if (result) {
518 } else {
520 }
521}
522
526 bool result = File::DeleteLink(namespc, path);
527 if (result) {
529 } else {
531 }
532}
533
536 const char* old_path = DartUtils::GetNativeTypedDataArgument(args, 1);
537 const char* new_path = DartUtils::GetNativeStringArgument(args, 2);
538 bool result = File::Rename(namespc, old_path, new_path);
539 if (result) {
541 } else {
543 }
544}
545
548 const char* old_path = DartUtils::GetNativeTypedDataArgument(args, 1);
549 const char* new_path = DartUtils::GetNativeStringArgument(args, 2);
550 bool result = File::RenameLink(namespc, old_path, new_path);
551 if (result) {
553 } else {
555 }
556}
557
560 const char* old_path = DartUtils::GetNativeTypedDataArgument(args, 1);
561 const char* new_path = DartUtils::GetNativeStringArgument(args, 2);
562 bool result = File::Copy(namespc, old_path, new_path);
563 if (result) {
565 } else {
567 }
568}
569
572 const char* path = nullptr;
573 const char* str = DartUtils::GetNativeTypedDataArgument(args, 1);
574 path = File::GetCanonicalPath(namespc, str);
575 if (path != nullptr) {
578 } else {
580 }
581}
582
584 const int64_t fd = DartUtils::GetNativeIntegerArgument(args, 0);
585 File* file = File::OpenStdio(static_cast<int>(fd));
586 Dart_SetIntegerReturnValue(args, reinterpret_cast<intptr_t>(file));
587}
588
591 ASSERT((fd == STDIN_FILENO) || (fd == STDOUT_FILENO) ||
592 (fd == STDERR_FILENO));
594 if (type == File::StdioHandleType::kTypeError) {
596 } else {
598 }
599}
600
604 bool follow_links = DartUtils::GetNativeBooleanArgument(args, 2);
605 File::Type type = File::GetType(namespc, path, follow_links);
606 Dart_SetIntegerReturnValue(args, static_cast<int>(type));
607}
608
612
613 int64_t stat_data[File::kStatSize];
614 File::Stat(namespc, path, stat_data);
615 if (stat_data[File::kType] == File::kDoesNotExist) {
617 return;
618 }
619 Dart_Handle returned_data =
621 ThrowIfError(returned_data);
622 Dart_TypedData_Type data_type_unused;
623 void* data_location;
624 intptr_t data_length_unused;
626 returned_data, &data_type_unused, &data_location, &data_length_unused);
627 ThrowIfError(status);
628 memmove(data_location, stat_data, File::kStatSize * sizeof(int64_t));
629 status = Dart_TypedDataReleaseData(returned_data);
630 ThrowIfError(status);
631 Dart_SetReturnValue(args, returned_data);
632}
633
636 const char* path_1 = DartUtils::GetNativeStringArgument(args, 1);
637 const char* path_2 = DartUtils::GetNativeStringArgument(args, 2);
638 File::Identical result = File::AreIdentical(namespc, path_1, namespc, path_2);
639 if (result == File::kError) {
641 } else {
643 }
644}
645
646#define IS_SEPARATOR(c) ((c) == '/' || (c) == 0)
647
648// Checks that if we increment this index forward, we'll still have enough space
649// for a null terminator within PATH_MAX bytes.
650#define CHECK_CAN_INCREMENT(i) \
651 if ((i) + 1 >= outlen) { \
652 return -1; \
653 }
654
655intptr_t File::CleanUnixPath(const char* in, char* out, intptr_t outlen) {
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}
727
728static int64_t CObjectInt32OrInt64ToInt64(CObject* cobject) {
729 ASSERT(cobject->IsInt32OrInt64());
730 int64_t result;
731 if (cobject->IsInt32()) {
732 CObjectInt32 value(cobject);
733 result = value.Value();
734 } else {
735 CObjectInt64 value(cobject);
736 result = value.Value();
737 }
738 return result;
739}
740
742 CObjectIntptr value(cobject);
743 return reinterpret_cast<File*>(value.Value());
744}
745
747 CObjectIntptr value(cobject);
748 return reinterpret_cast<Namespace*>(value.Value());
749}
750
752 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
754 }
755 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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}
764
766 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
768 }
769 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
781}
782
784 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
786 }
787 Namespace* namespc = CObjectToNamespacePointer(request[0]);
789
790 File* readPipe;
791 File* writePipe;
792 if (!CreatePipe(namespc, &readPipe, &writePipe)) {
793 return CObject::NewOSError();
794 }
795
798 CObject::NewNativePointer(reinterpret_cast<intptr_t>(readPipe),
799 sizeof(*readPipe), ReleaseFile));
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}
807
809 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
811 }
812 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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);
824 namespc, reinterpret_cast<const char*>(filename.Buffer()), file_mode);
825 if (file == nullptr) {
826 return CObject::NewOSError();
827 }
829 reinterpret_cast<intptr_t>(file), sizeof(*file), ReleaseFile));
830}
831
833 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
834 return CObject::False();
835 }
836 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
845}
846
848 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
850 }
851 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
863}
864
866 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
868 }
869 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
881}
882
884 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
886 }
887 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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 }
899}
900
902 if ((request.Length() != 1) || !request[0]->IsIntptr()) {
903 return new CObjectIntptr(CObject::NewIntptr(-1));
904 }
905 File* file = CObjectToFilePointer(request[0]);
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}
917
919 if ((request.Length() != 1) || !request[0]->IsIntptr()) {
921 }
922 File* file = CObjectToFilePointer(request[0]);
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}
933
935 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
937 }
938 File* file = CObjectToFilePointer(request[0]);
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}
949
951 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
953 }
954 File* file = CObjectToFilePointer(request[0]);
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}
968
970 if ((request.Length() != 1) || !request[0]->IsIntptr()) {
972 }
973 File* file = CObjectToFilePointer(request[0]);
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}
984
986 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
988 }
989 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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}
1002
1004 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1006 }
1007 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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}
1021
1023 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1025 }
1026 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
1038}
1039
1041 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1043 }
1044 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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}
1058
1060 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1062 }
1063 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
1075}
1076
1078 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1080 }
1081 File* file = CObjectToFilePointer(request[0]);
1083 if (file->IsClosed()) {
1084 return CObject::FileClosedError();
1085 }
1086 return file->Flush() ? CObject::True() : CObject::NewOSError();
1087}
1088
1090 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1092 }
1093 File* file = CObjectToFilePointer(request[0]);
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 }
1107}
1108
1110 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1112 }
1113 File* file = CObjectToFilePointer(request[0]);
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)
1126}
1127
1129 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1131 }
1132 File* file = CObjectToFilePointer(request[0]);
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);
1158 result->SetAt(0, new CObjectIntptr(CObject::NewInt32(0)));
1159 result->SetAt(1, external_array);
1160 return result;
1161}
1162
1164 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1166 }
1167 File* file = CObjectToFilePointer(request[0]);
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);
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}
1198
1200 switch (type) {
1204 return 1;
1207 return 2;
1211 return 4;
1215 return 8;
1219 return 16;
1220 default:
1221 break;
1222 }
1223 UNREACHABLE();
1224 return -1;
1225}
1226
1228 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1230 }
1231 File* file = CObjectToFilePointer(request[0]);
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)
1268}
1269
1271 if ((request.Length() != 3) || !request[0]->IsIntptr()) {
1273 }
1274 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
1286}
1287
1289 if ((request.Length() != 2) || !request[0]->IsIntptr()) {
1291 }
1292 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
1302}
1303
1305 if ((request.Length() != 3) || !request[0]->IsIntptr()) {
1307 }
1308 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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()
1320}
1321
1323 if ((request.Length() != 2) || !request[0]->IsIntptr()) {
1325 }
1326 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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 }
1338}
1339
1341 if ((request.Length() != 3) || !request[0]->IsIntptr()) {
1343 }
1344 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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}
1356
1358 if ((request.Length() != 3) || !request[0]->IsIntptr()) {
1360 }
1361 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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 }
1374}
1375
1377 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1379 }
1380 Namespace* namespc = CObjectToNamespacePointer(request[0]);
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 }
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));
1397 wrapper->SetAt(1, result);
1398 return wrapper;
1399}
1400
1402 if ((request.Length() < 1) || !request[0]->IsIntptr()) {
1404 }
1405 File* file = CObjectToFilePointer(request[0]);
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()
1420}
1421
1422// Inspired by sdk/lib/core/uri.dart
1423UriDecoder::UriDecoder(const char* uri) : uri_(uri) {
1424 const char* ch = uri;
1425 while ((*ch != '\0') && (*ch != '%')) {
1426 ch++;
1427 }
1428 if (*ch == 0) {
1429 // if there are no '%', nothing to decode, refer to original as decoded.
1430 decoded_ = const_cast<char*>(uri);
1431 return;
1432 }
1433 const intptr_t len = strlen(uri);
1434 // Decoded string should be shorter than original because of
1435 // percent-encoding.
1436 char* dest = reinterpret_cast<char*>(malloc(len + 1));
1437 int i = ch - uri;
1438 // Copy all characters up to first '%' at index i.
1439 strncpy(dest, uri, i);
1440 decoded_ = dest;
1441 dest += i;
1442 while (*ch != '\0') {
1443 if (*ch != '%') {
1444 *(dest++) = *(ch++);
1445 continue;
1446 }
1447 if ((i + 3 > len) || !HexCharPairToByte(ch + 1, dest)) {
1448 free(decoded_);
1449 decoded_ = nullptr;
1450 return;
1451 }
1452 ++dest;
1453 ch += 3;
1454 }
1455 *dest = 0;
1456}
1457
1459 if (uri_ != decoded_ && decoded_ != nullptr) {
1460 free(decoded_);
1461 }
1462}
1463
1464bool UriDecoder::HexCharPairToByte(const char* pch, char* const dest) {
1465 int byte = 0;
1466 for (int i = 0; i < 2; i++) {
1467 char char_code = *(pch + i);
1468 if (0x30 <= char_code && char_code <= 0x39) {
1469 byte = byte * 16 + char_code - 0x30;
1470 } else {
1471 // Check ranges A-F (0x41-0x46) and a-f (0x61-0x66).
1472 char_code |= 0x20;
1473 if (0x61 <= char_code && char_code <= 0x66) {
1474 byte = byte * 16 + char_code - 0x57;
1475 } else {
1476 return false;
1477 }
1478 }
1479 }
1480 *dest = byte;
1481 return true;
1482}
1483
1484} // namespace bin
1485} // namespace dart
static SkPath path1()
static SkPath path2()
#define UNREACHABLE()
Definition: assert.h:248
#define DEBUG_ASSERT(cond)
Definition: assert.h:321
GLenum type
#define FUNCTION_NAME(name)
Definition: builtin.h:19
void SetAt(intptr_t index, CObject *value)
Definition: dartutils.h:548
intptr_t Length() const
Definition: dartutils.h:544
bool Value() const
Definition: dartutils.h:465
const char * CString() const
Definition: dartutils.h:534
const uint8_t * Buffer() const
Definition: dartutils.h:583
Dart_TypedData_Type Type() const
Definition: dartutils.h:579
const uint8_t * Buffer() const
Definition: dartutils.h:594
static Dart_CObject * NewString(const char *str)
Definition: dartutils.cc:927
static CObject * IllegalArgumentError()
Definition: dartutils.cc:1026
static CObject * FileClosedError()
Definition: dartutils.cc:1032
static void FreeIOBufferData(Dart_CObject *object)
Definition: dartutils.cc:1019
bool IsInt32OrInt64()
Definition: dartutils.h:349
static Dart_CObject * NewIntptr(intptr_t value)
Definition: dartutils.cc:914
static Dart_CObject * NewIOBuffer(int64_t length)
Definition: dartutils.cc:978
static CObject * Bool(bool value)
Definition: dartutils.cc:891
static Dart_CObject * NewArray(intptr_t length)
Definition: dartutils.cc:936
static CObject * True()
Definition: dartutils.cc:883
static constexpr int kSuccess
Definition: dartutils.h:332
static Dart_CObject * NewNativePointer(intptr_t ptr, intptr_t size, Dart_HandleFinalizer callback)
Definition: dartutils.cc:968
static Dart_CObject * NewInt32(int32_t value)
Definition: dartutils.cc:902
static Dart_CObject * NewInt64(int64_t value)
Definition: dartutils.cc:908
static CObject * NewOSError()
Definition: dartutils.cc:1038
static void ShrinkIOBuffer(Dart_CObject *cobject, int64_t new_length)
Definition: dartutils.cc:993
static CObject * Null()
Definition: dartutils.cc:879
static CObject * False()
Definition: dartutils.cc:887
static int64_t GetNativeIntegerArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:156
static const char * GetNativeTypedDataArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:195
static Dart_Handle NewDartOSError()
Definition: dartutils.cc:702
static bool GetBooleanValue(Dart_Handle bool_obj)
Definition: dartutils.cc:137
static bool GetInt64Value(Dart_Handle value_obj, int64_t *value)
Definition: dartutils.cc:112
static intptr_t GetNativeIntptrArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:166
static Dart_Handle NewString(const char *str)
Definition: dartutils.h:214
static Dart_Handle NewDartArgumentError(const char *message)
Definition: dartutils.cc:746
static Dart_Handle NewInternalError(const char *message)
Definition: dartutils.cc:781
static Dart_Handle GetDartType(const char *library_url, const char *class_name)
Definition: dartutils.cc:696
static const char * GetNativeStringArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:175
static bool GetNativeBooleanArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:146
static bool CreatePipe(Namespace *namespc, File **readPipe, File **writePipe)
static CObject * PositionRequest(const CObjectArray &request)
Definition: file.cc:918
static CObject * OpenRequest(const CObjectArray &request)
Definition: file.cc:808
static CObject * TypeRequest(const CObjectArray &request)
Definition: file.cc:1340
static CObject * LengthFromPathRequest(const CObjectArray &request)
Definition: file.cc:985
static bool DeleteLink(Namespace *namespc, const char *path)
static CObject * FlushRequest(const CObjectArray &request)
Definition: file.cc:1077
static CObject * TruncateRequest(const CObjectArray &request)
Definition: file.cc:950
static CObject * DeleteRequest(const CObjectArray &request)
Definition: file.cc:832
static CObject * ReadIntoRequest(const CObjectArray &request)
Definition: file.cc:1163
static const char * GetCanonicalPath(Namespace *namespc, const char *path, char *dest=nullptr, int dest_size=0)
static CObject * ReadByteRequest(const CObjectArray &request)
Definition: file.cc:1089
static CObject * RenameRequest(const CObjectArray &request)
Definition: file.cc:847
static CObject * ExistsRequest(const CObjectArray &request)
Definition: file.cc:751
static CObject * SetLastModifiedRequest(const CObjectArray &request)
Definition: file.cc:1059
static bool SetLastAccessed(Namespace *namespc, const char *path, int64_t millis)
static CObject * StatRequest(const CObjectArray &request)
Definition: file.cc:1376
@ kDoesNotExist
Definition: file.h:81
static CObject * CopyRequest(const CObjectArray &request)
Definition: file.cc:865
static bool SetLastModified(Namespace *namespc, const char *path, int64_t millis)
static CObject * SetPositionRequest(const CObjectArray &request)
Definition: file.cc:934
static time_t LastModified(Namespace *namespc, const char *path)
static void Stat(Namespace *namespc, const char *path, int64_t *data)
static bool Create(Namespace *namespc, const char *path, bool exclusive)
static CObject * LinkTargetRequest(const CObjectArray &request)
Definition: file.cc:1322
static bool Rename(Namespace *namespc, const char *old_path, const char *new_path)
static CObject * WriteFromRequest(const CObjectArray &request)
Definition: file.cc:1227
static bool Delete(Namespace *namespc, const char *path)
@ kIdentical
Definition: file.h:84
static CObject * DeleteLinkRequest(const CObjectArray &request)
Definition: file.cc:1288
static CObject * ReadRequest(const CObjectArray &request)
Definition: file.cc:1128
DartFileOpenMode
Definition: file.h:67
static CObject * RenameLinkRequest(const CObjectArray &request)
Definition: file.cc:1304
static int64_t LengthFromPath(Namespace *namespc, const char *path)
static CObject * CreateLinkRequest(const CObjectArray &request)
Definition: file.cc:1270
static bool Copy(Namespace *namespc, const char *old_path, const char *new_path)
static time_t LastAccessed(Namespace *namespc, const char *path)
static intptr_t CleanUnixPath(const char *in, char *out, intptr_t outlen)
Definition: file.cc:655
static CObject * IdenticalRequest(const CObjectArray &request)
Definition: file.cc:1357
bool result
Definition: file.h:170
static CObject * LengthRequest(const CObjectArray &request)
Definition: file.cc:969
static CObject * WriteByteRequest(const CObjectArray &request)
Definition: file.cc:1109
static bool Exists(Namespace *namespc, const char *path)
static File * Open(Namespace *namespc, const char *path, FileOpenMode mode)
static FileOpenMode DartModeToFileMode(DartFileOpenMode mode)
Definition: file_support.cc:89
static CObject * CreateRequest(const CObjectArray &request)
Definition: file.cc:765
static CObject * LastAccessedRequest(const CObjectArray &request)
Definition: file.cc:1003
static CObject * ResolveSymbolicLinksRequest(const CObjectArray &request)
Definition: file.cc:883
static Identical AreIdentical(Namespace *namespc_1, const char *file_1, Namespace *namespc_2, const char *file_2)
static const char * LinkTarget(Namespace *namespc, const char *pathname, char *dest=nullptr, int dest_size=0)
static bool CreateLink(Namespace *namespc, const char *path, const char *target)
static CObject * CreatePipeRequest(const CObjectArray &request)
Definition: file.cc:783
static File * OpenStdio(int fd)
static StdioHandleType GetStdioHandleType(int fd)
static CObject * SetLastAccessedRequest(const CObjectArray &request)
Definition: file.cc:1022
static Type GetType(Namespace *namespc, const char *path, bool follow_links)
static CObject * CloseRequest(const CObjectArray &request)
Definition: file.cc:901
static CObject * LockRequest(const CObjectArray &request)
Definition: file.cc:1401
static CObject * LastModifiedRequest(const CObjectArray &request)
Definition: file.cc:1040
static bool RenameLink(Namespace *namespc, const char *old_path, const char *new_path)
static Dart_Handle Allocate(intptr_t size, uint8_t **buffer)
Definition: io_buffer.cc:12
static Namespace * GetNamespace(Dart_NativeArguments args, intptr_t index)
Definition: namespace.cc:101
UriDecoder(const char *uri)
Definition: file.cc:1423
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
struct _Dart_NativeArguments * Dart_NativeArguments
Definition: dart_api.h:3019
Dart_TypedData_Type
Definition: dart_api.h:2612
@ Dart_TypedData_kFloat32x4
Definition: dart_api.h:2626
@ Dart_TypedData_kInt32x4
Definition: dart_api.h:2625
@ Dart_TypedData_kUint8
Definition: dart_api.h:2615
@ Dart_TypedData_kUint32
Definition: dart_api.h:2620
@ Dart_TypedData_kInt32
Definition: dart_api.h:2619
@ Dart_TypedData_kUint16
Definition: dart_api.h:2618
@ Dart_TypedData_kFloat64x2
Definition: dart_api.h:2627
@ Dart_TypedData_kUint64
Definition: dart_api.h:2622
@ Dart_TypedData_kFloat32
Definition: dart_api.h:2623
@ Dart_TypedData_kInt16
Definition: dart_api.h:2617
@ Dart_TypedData_kFloat64
Definition: dart_api.h:2624
@ Dart_TypedData_kUint8Clamped
Definition: dart_api.h:2616
@ Dart_TypedData_kInt8
Definition: dart_api.h:2614
@ Dart_TypedData_kInt64
Definition: dart_api.h:2621
struct _Dart_FinalizableHandle * Dart_FinalizableHandle
Definition: dart_api.h:261
#define ASSERT(E)
glong glong end
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint8_t value
GAsyncResult * result
uint32_t * target
size_t length
void FUNCTION_NAME() File_WriteByte(Dart_NativeArguments args)
Definition: file.cc:156
void FUNCTION_NAME() File_Rename(Dart_NativeArguments args)
Definition: file.cc:534
void FUNCTION_NAME() File_AreIdentical(Dart_NativeArguments args)
Definition: file.cc:634
void FUNCTION_NAME() File_RenameLink(Dart_NativeArguments args)
Definition: file.cc:546
void FUNCTION_NAME() File_SetPosition(Dart_NativeArguments args)
Definition: file.cc:321
void FUNCTION_NAME() File_Read(Dart_NativeArguments args)
Definition: file.cc:174
void FUNCTION_NAME() File_ReadByte(Dart_NativeArguments args)
Definition: file.cc:142
void FUNCTION_NAME() File_GetStdioHandleType(Dart_NativeArguments args)
Definition: file.cc:589
void FUNCTION_NAME() File_GetFD(Dart_NativeArguments args)
Definition: file.cc:70
static Dart_Handle ThrowIfError(Dart_Handle handle)
Definition: dartutils.h:31
void FUNCTION_NAME() File_OpenStdio(Dart_NativeArguments args)
Definition: file.cc:583
void FUNCTION_NAME() File_GetType(Dart_NativeArguments args)
Definition: file.cc:601
static void ReleaseFile(void *isolate_callback_data, void *peer)
Definition: file.cc:74
void FUNCTION_NAME() File_Lock(Dart_NativeArguments args)
Definition: file.cc:435
static bool IsFile(Dart_Handle file_obj)
Definition: file.cc:25
static constexpr int kFileNativeFieldIndex
Definition: file.cc:22
static File * CObjectToFilePointer(CObject *cobject)
Definition: file.cc:741
void FUNCTION_NAME() File_Delete(Dart_NativeArguments args)
Definition: file.cc:512
static File * GetFile(Dart_NativeArguments args)
Definition: file.cc:37
void FUNCTION_NAME() File_CreateLink(Dart_NativeArguments args)
Definition: file.cc:471
void FUNCTION_NAME() File_Exists(Dart_NativeArguments args)
Definition: file.cc:108
void FUNCTION_NAME() File_LengthFromPath(Dart_NativeArguments args)
Definition: file.cc:364
void FUNCTION_NAME() File_Close(Dart_NativeArguments args)
Definition: file.cc:115
void FUNCTION_NAME() File_Copy(Dart_NativeArguments args)
Definition: file.cc:558
void FUNCTION_NAME() File_LastModified(Dart_NativeArguments args)
Definition: file.cc:375
void FUNCTION_NAME() File_SetLastAccessed(Dart_NativeArguments args)
Definition: file.cc:411
void FUNCTION_NAME() File_SetPointer(Dart_NativeArguments args)
Definition: file.cc:79
static void SetFile(Dart_Handle dart_this, intptr_t file_pointer)
Definition: file.cc:51
void FUNCTION_NAME() File_Position(Dart_NativeArguments args)
Definition: file.cc:310
void FUNCTION_NAME() File_LinkTarget(Dart_NativeArguments args)
Definition: file.cc:500
void FUNCTION_NAME() File_CreatePipe(Dart_NativeArguments args)
Definition: file.cc:481
void FUNCTION_NAME() File_SetLastModified(Dart_NativeArguments args)
Definition: file.cc:386
void FUNCTION_NAME() File_GetPointer(Dart_NativeArguments args)
Definition: file.cc:58
void FUNCTION_NAME() File_Create(Dart_NativeArguments args)
Definition: file.cc:458
void FUNCTION_NAME() File_Open(Dart_NativeArguments args)
Definition: file.cc:89
static int64_t CObjectInt32OrInt64ToInt64(CObject *cobject)
Definition: file.cc:728
static int SizeInBytes(Dart_TypedData_Type type)
Definition: file.cc:1199
void FUNCTION_NAME() File_Length(Dart_NativeArguments args)
Definition: file.cc:353
void FUNCTION_NAME() File_Stat(Dart_NativeArguments args)
Definition: file.cc:609
void FUNCTION_NAME() File_Flush(Dart_NativeArguments args)
Definition: file.cc:425
void FUNCTION_NAME() File_Truncate(Dart_NativeArguments args)
Definition: file.cc:337
void FUNCTION_NAME() File_WriteFrom(Dart_NativeArguments args)
Definition: file.cc:268
void FUNCTION_NAME() File_ResolveSymbolicLinks(Dart_NativeArguments args)
Definition: file.cc:570
void FUNCTION_NAME() File_LastAccessed(Dart_NativeArguments args)
Definition: file.cc:400
void FUNCTION_NAME() File_ReadInto(Dart_NativeArguments args)
Definition: file.cc:214
void FUNCTION_NAME() File_DeleteLink(Dart_NativeArguments args)
Definition: file.cc:523
static Namespace * CObjectToNamespacePointer(CObject *cobject)
Definition: directory.cc:197
Definition: dart_vm.cc:33
const char *const name
DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, int index, intptr_t *value)
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args, bool retval)
void * malloc(size_t size)
Definition: allocation.cc:19
DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception)
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT Dart_FinalizableHandle Dart_NewFinalizableHandle(Dart_Handle object, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, intptr_t length)
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, Dart_Handle retval)
DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, Dart_TypedData_Type *type, void **data, intptr_t *len)
DART_EXPORT Dart_Isolate Dart_CurrentIsolate()
DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, intptr_t index, Dart_Handle value)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, int index, intptr_t value)
DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, int64_t retval)
DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object, Dart_Handle type, bool *value)
constexpr intptr_t kMillisecondsPerSecond
Definition: globals.h:560
DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, intptr_t offset, const uint8_t *native_array, intptr_t length)
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t *len)
DART_EXPORT Dart_Handle Dart_NewList(intptr_t length)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
DART_EXPORT bool Dart_IsList(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
DART_EXPORT bool Dart_IsTypedData(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_Null()
static int8_t data[kExtLength]
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
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
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
dest
Definition: zip.py:79
union _Dart_CObject::@86 value
uint8_t * data
struct _Dart_CObject::@86::@91 as_external_typed_data
#define IS_SEPARATOR(c)
Definition: file.cc:646
#define CHECK_CAN_INCREMENT(i)
Definition: file.cc:650