Flutter Engine
The Flutter Engine
SkOSFile.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9// TODO: add unittests for all these operations
10
11#ifndef SkOSFile_DEFINED
12#define SkOSFile_DEFINED
13
14#include <stdio.h>
15
18
22};
23
24FILE* sk_fopen(const char path[], SkFILE_Flags);
25void sk_fclose(FILE*);
26
27size_t sk_fgetsize(FILE*);
28
29size_t sk_fwrite(const void* buffer, size_t byteCount, FILE*);
30
31void sk_fflush(FILE*);
32void sk_fsync(FILE*);
33
34size_t sk_ftell(FILE*);
35
36/** Maps a file into memory. Returns the address and length on success, NULL otherwise.
37 * The mapping is read only.
38 * When finished with the mapping, free the returned pointer with sk_fmunmap.
39 */
40void* sk_fmmap(FILE* f, size_t* length);
41
42/** Maps a file descriptor into memory. Returns the address and length on success, NULL otherwise.
43 * The mapping is read only.
44 * When finished with the mapping, free the returned pointer with sk_fmunmap.
45 */
46void* sk_fdmmap(int fd, size_t* length);
47
48/** Unmaps a file previously mapped by sk_fmmap or sk_fdmmap.
49 * The length parameter must be the same as returned from sk_fmmap.
50 */
51void sk_fmunmap(const void* addr, size_t length);
52
53/** Returns true if the two point at the exact same filesystem object. */
54bool sk_fidentical(FILE* a, FILE* b);
55
56/** Returns the underlying file descriptor for the given file.
57 * The return value will be < 0 on failure.
58 */
59int sk_fileno(FILE* f);
60
61/** Returns true if something (file, directory, ???) exists at this path,
62 * and has the specified access flags.
63 */
64bool sk_exists(const char *path, SkFILE_Flags = (SkFILE_Flags)0);
65
66// Returns true if a directory exists at this path.
67bool sk_isdir(const char *path);
68
69// Like pread, but may affect the file position marker.
70// Returns the number of bytes read or SIZE_MAX if failed.
71size_t sk_qread(FILE*, void* buffer, size_t count, size_t offset);
72
73
74// Create a new directory at this path; returns true if successful.
75// If the directory already existed, this will return true.
76// Description of the error, if any, will be written to stderr.
77bool sk_mkdir(const char* path);
78
79class SkOSFile {
80public:
81 class Iter {
82 public:
83 // SPI for module use.
84 SK_SPI Iter();
85 SK_SPI Iter(const char path[], const char suffix[] = nullptr);
86 SK_SPI ~Iter();
87
88 SK_SPI void reset(const char path[], const char suffix[] = nullptr);
89 /** If getDir is true, only returns directories.
90 Results are undefined if true and false calls are
91 interleaved on a single iterator.
92 */
93 SK_SPI bool next(SkString* name, bool getDir = false);
94
95 static const size_t kStorageSize = 40;
96 private:
97 alignas(void*) alignas(double) char fSelf[kStorageSize];
98 };
99};
100
101#endif
int count
Definition: FontMgrTest.cpp:50
#define SK_SPI
Definition: SkAPI.h:41
bool sk_mkdir(const char *path)
FILE * sk_fopen(const char path[], SkFILE_Flags)
void sk_fclose(FILE *)
size_t sk_fwrite(const void *buffer, size_t byteCount, FILE *)
int sk_fileno(FILE *f)
size_t sk_ftell(FILE *)
size_t sk_qread(FILE *, void *buffer, size_t count, size_t offset)
void sk_fmunmap(const void *addr, size_t length)
bool sk_exists(const char *path, SkFILE_Flags=(SkFILE_Flags) 0)
SkFILE_Flags
Definition: SkOSFile.h:19
@ kRead_SkFILE_Flag
Definition: SkOSFile.h:20
@ kWrite_SkFILE_Flag
Definition: SkOSFile.h:21
void sk_fflush(FILE *)
bool sk_fidentical(FILE *a, FILE *b)
void * sk_fdmmap(int fd, size_t *length)
void sk_fsync(FILE *)
size_t sk_fgetsize(FILE *)
void * sk_fmmap(FILE *f, size_t *length)
bool sk_isdir(const char *path)
SK_SPI void reset(const char path[], const char suffix[]=nullptr)
SK_SPI bool next(SkString *name, bool getDir=false)
static const size_t kStorageSize
Definition: SkOSFile.h:95
static bool b
struct MyStruct a[10]
size_t length
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
Definition: switches.h:32
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
def getDir(rootdir, target)
SeparatedVector2 offset