Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..
358 views

The C function "Rename" don't works in LR 12.53?

Jump to solution

I'm trying to do a simple function to rename an specific file on my PC Host.

this is my code

void changeName(){
    int ret;
    char buffer_old[101] = "C:\Dados\Shared\Sprinter 14.txt";
    char buffer_new[101] = "C:\Dados\Shared\Sprinter 14 test.txt";
     ret = rename(buffer_old, buffer_new);
    if(ret == 0)
    {
        lr_log_message("ok");
    } 
    else
    {
           lr_log_message("fail");
    }
}

The function is called from the Truclient action correctly, but it fail.

can  anyone help me?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: The C function "Rename" don't works in LR 12.53?

Jump to solution

In a C-string you need to escape two characters: \ and ", and the escape character is \. So you need to use for your filename:

char buffer_old[101] = "C:\\Dados\\Shared\\Sprinter 14.txt";

Note: that you can also use forward slash. The backward slash is only needed for CMD.exe. All (most?) API of Windows accept forward slashes in path names.

Signature:
Reward community members who take time to respond and help.

View solution in original post

2 Replies
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: The C function "Rename" don't works in LR 12.53?

Jump to solution

In a C-string you need to escape two characters: \ and ", and the escape character is \. So you need to use for your filename:

char buffer_old[101] = "C:\\Dados\\Shared\\Sprinter 14.txt";

Note: that you can also use forward slash. The backward slash is only needed for CMD.exe. All (most?) API of Windows accept forward slashes in path names.

Signature:
Reward community members who take time to respond and help.

View solution in original post

Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..

Re: The C function "Rename" don't works in LR 12.53?

Jump to solution

Thank you Remmezwall, your tip save me.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.