Algorithm to Obtain Destination File in moveFileTo()

Depending on what you’re doing exactly the compiler might be trying to call the copy constructor rather than the assignment operator (if the object hasn’t yet been constructed).


class CustomFile
{
public:
    CustomFile& operator= (const File& input);
    
private:
    File juceFile;
};

//==============================================================================

CustomFile& CustomFile::operator= (const File& input)
{
    juceFile = input;
    return *this;
}

//==============================================================================

int main (int argc, char* argv[])
{
    CustomFile f1 = "/file/path";          // compiler error, copy constructor not assignemnt
    CustomFile f2 = String ("/file/path"); // compiler error, copy constructor not assignemnt
    CustomFile f3 = File ("/file/path");   // compiler error, copy constructor not assignemnt
    
    CustomFile f4;
    f4 = "/file/path";          // compiler error, no overload for assignment operator for char[n]
    
    CustomFile f5;
    f5 = String ("/file/path"); // OK

    CustomFile f6;
    f6 = File ("/file/path");   // OK
    
    return 0;
}

Again, did you return a temporary copy of your juceFile member or a reference? If you’re assigning to a temporary copy then it won’t work. This pattern should work:

class CustomFile
{
public:
...
    
    File& getFile()             { return juceFile; }
    const File& getFile() const { return juceFile; }
    
private:
    File juceFile;
};

Sorry, I made a mistake, I didn’t use a getter, I used a setter to set it.

void CustomFile::setJuceFile(const File &input)
{
    juceFile = input;
}