Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2018 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "atom/common/api/file_output_stream.h" | ||
|
||
namespace atom { | ||
|
||
FileOutputStream::FileOutputStream(const base::FilePath& file_path) | ||
: file_(file_path, | ||
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE) {} | ||
|
||
bool FileOutputStream::IsValid() const { | ||
return file_.IsValid(); | ||
} | ||
|
||
bool FileOutputStream::IsComplete() const { | ||
return is_complete_; | ||
} | ||
|
||
int FileOutputStream::GetChunkSize() { | ||
return 65536; | ||
} | ||
|
||
void FileOutputStream::EndOfStream() { | ||
is_complete_ = true; | ||
} | ||
|
||
v8::OutputStream::WriteResult FileOutputStream::WriteAsciiChunk(char* data, | ||
int size) { | ||
auto bytes_written = file_.WriteAtCurrentPos(data, size); | ||
return bytes_written == size ? kContinue : kAbort; | ||
} | ||
|
||
} // namespace atom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2018 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ATOM_COMMON_API_FILE_OUTPUT_STREAM_H_ | ||
#define ATOM_COMMON_API_FILE_OUTPUT_STREAM_H_ | ||
|
||
#include "base/files/file.h" | ||
#include "base/files/file_path.h" | ||
#include "v8/include/v8-profiler.h" | ||
|
||
namespace atom { | ||
|
||
class FileOutputStream : public v8::OutputStream { | ||
public: | ||
FileOutputStream(const base::FilePath& file_path); | ||
|
||
bool IsValid() const; | ||
bool IsComplete() const; | ||
|
||
// v8::OutputStream | ||
virtual int GetChunkSize(); | ||
virtual void EndOfStream(); | ||
virtual v8::OutputStream::WriteResult WriteAsciiChunk(char* data, int size); | ||
|
||
private: | ||
base::File file_; | ||
bool is_complete_ = false; | ||
}; | ||
|
||
} // namespace atom | ||
|
||
#endif // ATOM_COMMON_API_FILE_OUTPUT_STREAM_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters