mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
The file was overwritten when transferring a file that already existed in the downloads folder. With this change we now add " (x)", where x is an incrementing number, starting at 1, using the next non-existing number, to the file name, just before the first dot, or at the end if no dot. This has been applied to the GetDownloadPath method in the platform api.
PiperOrigin-RevId: 457530287
This commit is contained in:
committed by
Copybara-Service
parent
9ce81d8534
commit
87c76ea235
@@ -14,8 +14,10 @@
|
||||
|
||||
#include "internal/platform/implementation/shared/file.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
@@ -42,10 +44,9 @@ std::unique_ptr<IOFile> IOFile::CreateOutputFile(const absl::string_view path) {
|
||||
}
|
||||
|
||||
IOFile::IOFile(const absl::string_view file_path)
|
||||
: file_(std::string(file_path.data(), file_path.size()),
|
||||
std::ios::binary | std::ios::out | std::ios::trunc),
|
||||
path_({file_path.data(), file_path.size()}),
|
||||
total_size_(0) {}
|
||||
: file_(), path_(file_path), total_size_(0) {
|
||||
file_.open(path_, std::ios::binary | std::ios::out);
|
||||
}
|
||||
|
||||
ExceptionOr<ByteArray> IOFile::Read(std::int64_t size) {
|
||||
if (!file_.is_open()) {
|
||||
|
||||
Reference in New Issue
Block a user