Skip to content

Commit

Permalink
renaming (close #147)
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Feb 27, 2019
1 parent b269d9c commit 9e6a962
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
[![Gitter chat](https://badges.gitter.im/skypjack/uvw.png)](https://gitter.im/skypjack/uvw)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=W2HF9FESD5LJY&lc=IT&item_name=Michele%20Caini&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)

[![Patreon](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/bePatron?u=11330786)
Do you have a **question** that doesn't require you to open an issue? Join the
[gitter channel](https://gitter.im/skypjack/uvw).

If you use `uvw` and you want to **say thanks** or **support** the project,
please **consider becoming a patron**:

[![Patreon](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/bePatron?c=1772573)

<!--
@endcond TURN_OFF_DOXYGEN
Expand Down
22 changes: 11 additions & 11 deletions src/uvw/fs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class FileReq final: public FsRequest<FileReq> {
static void fsReadCallback(uv_fs_t *req) {
auto ptr = reserve(req);
if(req->result < 0) { ptr->publish(ErrorEvent{req->result}); }
else { ptr->publish(FsEvent<Type::READ>{req->path, std::move(ptr->data), static_cast<std::size_t>(req->result)}); }
else { ptr->publish(FsEvent<Type::READ>{req->path, std::move(ptr->current), static_cast<std::size_t>(req->result)}); }
}

public:
Expand Down Expand Up @@ -516,8 +516,8 @@ class FileReq final: public FsRequest<FileReq> {
* @param len Length, as described in the official documentation.
*/
void read(int64_t offset, unsigned int len) {
data = std::unique_ptr<char[]>{new char[len]};
buffer = uv_buf_init(data.get(), len);
current = std::unique_ptr<char[]>{new char[len]};
buffer = uv_buf_init(current.get(), len);
uv_buf_t bufs[] = { buffer };
cleanupAndInvoke(&uv_fs_read, parent(), get(), file, bufs, 1, offset, &fsReadCallback);
}
Expand All @@ -536,13 +536,13 @@ class FileReq final: public FsRequest<FileReq> {
*/
std::pair<bool, std::pair<std::unique_ptr<const char[]>, std::size_t>>
readSync(int64_t offset, unsigned int len) {
data = std::unique_ptr<char[]>{new char[len]};
buffer = uv_buf_init(data.get(), len);
current = std::unique_ptr<char[]>{new char[len]};
buffer = uv_buf_init(current.get(), len);
uv_buf_t bufs[] = { buffer };
auto req = get();
cleanupAndInvokeSync(&uv_fs_read, parent(), req, file, bufs, 1, offset);
bool err = req->result < 0;
return std::make_pair(!err, std::make_pair(std::move(data), err ? 0 : std::size_t(req->result)));
return std::make_pair(!err, std::make_pair(std::move(current), err ? 0 : std::size_t(req->result)));
}

/**
Expand All @@ -559,8 +559,8 @@ class FileReq final: public FsRequest<FileReq> {
* @param offset Offset, as described in the official documentation.
*/
void write(std::unique_ptr<char[]> buf, unsigned int len, int64_t offset) {
this->data = std::move(buf);
uv_buf_t bufs[] = { uv_buf_init(this->data.get(), len) };
current = std::move(buf);
uv_buf_t bufs[] = { uv_buf_init(current.get(), len) };
cleanupAndInvoke(&uv_fs_write, parent(), get(), file, bufs, 1, offset, &fsResultCallback<Type::WRITE>);
}

Expand Down Expand Up @@ -594,8 +594,8 @@ class FileReq final: public FsRequest<FileReq> {
* * The amount of data written to the given path.
*/
std::pair<bool, std::size_t> writeSync(std::unique_ptr<char[]> buf, unsigned int len, int64_t offset) {
this->data = std::move(buf);
uv_buf_t bufs[] = { uv_buf_init(this->data.get(), len) };
current = std::move(buf);
uv_buf_t bufs[] = { uv_buf_init(current.get(), len) };
auto req = get();
cleanupAndInvokeSync(&uv_fs_write, parent(), req, file, bufs, 1, offset);
bool err = req->result < 0;
Expand Down Expand Up @@ -808,7 +808,7 @@ class FileReq final: public FsRequest<FileReq> {
operator FileHandle() const noexcept { return file; }

private:
std::unique_ptr<char[]> data{nullptr};
std::unique_ptr<char[]> current{nullptr};
uv_buf_t buffer{};
uv_file file{BAD_FD};
};
Expand Down

0 comments on commit 9e6a962

Please sign in to comment.