Skip to content

file:copy does not create missing directories in destination path #5738

@xlight05

Description

@xlight05

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):

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions