Lines Matching refs:file

3 // found in the LICENSE file.
13 // Reads from a file the given number of bytes, or until EOF is reached.
15 int ReadFully(base::PlatformFile file, int64 offset, char* data, int size) {
20 file, offset + total_bytes_read, &data[total_bytes_read],
36 // Writes the given number of bytes to a file.
38 int WriteFully(base::PlatformFile file, int64 offset,
44 file, offset + total_bytes_written, &data[total_bytes_written],
66 // Open a file that doesn't exist.
68 base::PlatformFile file = base::CreatePlatformFile(
71 EXPECT_EQ(base::kInvalidPlatformFileValue, file);
74 // Open or create a file.
77 file = base::CreatePlatformFile(
80 EXPECT_NE(base::kInvalidPlatformFileValue, file);
83 base::ClosePlatformFile(file);
85 // Open an existing file.
87 file = base::CreatePlatformFile(
90 EXPECT_NE(base::kInvalidPlatformFileValue, file);
93 base::ClosePlatformFile(file);
95 // Create a file that exists.
96 file = base::CreatePlatformFile(
99 EXPECT_EQ(base::kInvalidPlatformFileValue, file);
103 // Create or overwrite a file.
105 file = base::CreatePlatformFile(
108 EXPECT_NE(base::kInvalidPlatformFileValue, file);
111 base::ClosePlatformFile(file);
113 // Create a delete-on-close file.
116 file = base::CreatePlatformFile(
122 EXPECT_NE(base::kInvalidPlatformFileValue, file);
126 EXPECT_TRUE(base::ClosePlatformFile(file));
134 base::PlatformFile file = base::CreatePlatformFile(
140 EXPECT_NE(base::kInvalidPlatformFileValue, file);
145 // Write 0 bytes to the file.
146 int bytes_written = WriteFully(file, 0, data_to_write, 0);
149 // Write "test" to the file.
150 bytes_written = WriteFully(file, 0, data_to_write, kTestDataSize);
155 int bytes_read = ReadFully(file, kTestDataSize, data_read_1, kTestDataSize);
158 // Read from somewhere in the middle of the file.
160 bytes_read = ReadFully(file, kPartialReadOffset, data_read_1, kTestDataSize);
166 bytes_read = ReadFully(file, 0, data_read_1, 0);
169 // Read the entire file.
170 bytes_read = ReadFully(file, 0, data_read_1, kTestDataSize);
175 // Write past the end of the file.
178 bytes_written = WriteFully(file, kOffsetBeyondEndOfFile,
182 // Make sure the file was extended.
187 // Make sure the file was zero-padded.
189 bytes_read = ReadFully(file, 0, data_read_2, static_cast<int>(file_size));
198 // Close the file handle to allow the temp directory to be deleted.
199 base::ClosePlatformFile(file);
206 base::PlatformFile file = base::CreatePlatformFile(
212 EXPECT_NE(base::kInvalidPlatformFileValue, file);
214 // Write "test" to the file.
217 int bytes_written = WriteFully(file, 0, data_to_write, kTestDataSize);
220 // Extend the file.
223 EXPECT_TRUE(base::TruncatePlatformFile(file, kExtendedFileLength));
227 // Make sure the file was zero-padded.
229 int bytes_read = ReadFully(file, 0, data_read, static_cast<int>(file_size));
236 // Truncate the file.
238 EXPECT_TRUE(base::TruncatePlatformFile(file, kTruncatedFileLength));
242 // Make sure the file was truncated.
243 bytes_read = ReadFully(file, 0, data_read, kTestDataSize);
248 // Close the file handle to allow the temp directory to be deleted.
249 base::ClosePlatformFile(file);
255 base::PlatformFile file = base::CreatePlatformFile(
261 EXPECT_NE(base::kInvalidPlatformFileValue, file);
263 // Get info for a newly created file.
265 EXPECT_TRUE(base::GetPlatformFileInfo(file, &info));
278 // Write "test" to the file.
281 int bytes_written = WriteFully(file, 0, data, kTestDataSize);
293 EXPECT_TRUE(base::TouchPlatformFile(file, new_last_accessed,
296 // Make sure the file info was updated accordingly.
297 EXPECT_TRUE(base::GetPlatformFileInfo(file, &info));
318 // Close the file handle to allow the temp directory to be deleted.
319 base::ClosePlatformFile(file);