Skip to content
This repository was archived by the owner on May 4, 2018. It is now read-only.
This repository was archived by the owner on May 4, 2018. It is now read-only.

Error renaming file in Win32, if the file already exists #283

Closed

Description

@7phs

Calling fs__rename (src/win/fs.c) in Windows returns an error if the file on a new path already exists.
The behavior of "rename" (Linux) and "_wrename" (Windows) is different:

rename http://linux.die.net/man/3/rename : "If the link named by the new argument exists, it shall be removed and old renamed to new."

_wrename http://msdn.microsoft.com/en-us/library/zw5t957f.aspx : "The new name must not be the name of an existing file or directory."

To implement rename a file similar to the function "rename" (Linux) is better to use a function MoveFileEx http://msdn.microsoft.com/en-us/library/windows/desktop/aa365240.aspx

For example (src/win/fs.c):

void fs__rename(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
  int result = (TRUE==MoveFileEx(path, new_path, MOVEFILE_REPLACE_EXISTING) ? 0 : -1);
  SET_REQ_RESULT(req, result);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions