ballerina-library icon indicating copy to clipboard operation
ballerina-library copied to clipboard

`file:copy` does not create missing directories in destination path

Open xlight05 opened this issue 1 year ago • 0 comments

Description: $Subject.

$Subject. This doesn't return any error and works as a success case. However, the file is not copied to the destination. This should ideally copy the file by creating required dirs or return an error.

This only happens when the destination path directories does not exist.

Steps to reproduce:

  1. create a insert.sql file in package dir.
  2. run the following code.
import ballerina/file;
import ballerina/io;

public function main() returns error? {
    string sourcePath = "insert.sql";
    string destPath = "foo/insert.sql";
    file:Error? copy = file:copy(sourcePath, destPath);
    if copy is file:Error {
        io:println(copy.message());
    }
    io:println("done");
}


Affected Versions:

OS, DB, other environment details and versions:

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

xlight05 avatar Nov 07 '23 09:11 xlight05