Trying to upgrade an old opensourced code

Hi,
I am trying to upgrade some old open sourced project and I get plenty of errors.

I trying to join some sections of code with the errors

‘initializing’: cannot convert from ‘std::unique_ptr<juce::FileOutputStream,std::default_deletejuce::FileOutputStream>’ to ‘juce::FileOutputStream *’
‘nonexistent’: is not a member of ‘juce::File’
‘nonexistent’: undeclared identifier
‘initializing’: cannot convert from ‘std::unique_ptr<juce::FileInputStream,std::default_deletejuce::FileInputStream>’ to ‘juce::FileInputStream *’
‘nonexistent’: is not a member of ‘juce::File’
‘nonexistent’: undeclared identifier
‘initializing’: cannot convert from ‘std::unique_ptr<juce::FileOutputStream,std::default_deletejuce::FileOutputStream>’ to ‘juce::FileOutputStream *’
‘juce::thread::startThread’: no overloaded function could convert all the argument types
‘initializing’: cannot convert from ‘std::unique_ptr<juce::FileInputStream,std::default_deletejuce::FileInputStream>’ to ‘juce::FileInputStream’
binary ‘!’: no operator found which takes a left-hand operand of type ‘juce::FileInputStream’ (or there is no acceptable conversion)
built-in operator ‘!’ cannot be applied to an operand of type ‘juce::FileInputStream’
type ‘juce::FileInputStream’ does not have an overloaded member ‘operator ->’
‘->juce::FileInputStream::isExhausted’: left operand has ‘class’ type, use ‘.’
type ‘juce::FileInputStream’ does not have an overloaded member ‘operator ->’
‘->juce::FileInputStream::getTotalLength’: left operand has ‘class’ type, use ‘.’
type ‘juce::FileInputStream’ does not have an overloa

It looks like a lot of these errors are due to return types of functions changing from raw pointers to std::unique_ptr. I guess the code is calling File::getOutputStream(), but the return type of this function changed in 2020 to return a std::unique_ptr<FileOutputStream> instead of FileOutputStream*. You can get access to the raw pointer managed by a unique_ptr by calling get() on it.

So you think it’s ok to solve ?
I would like to attach code but i can’t because i am a new user :slight_smile:

bool HexFileLoader::loadFile(const File &inFile, String &statusMessage)
{
std::map<uint32, uint8> dumpMap;

// algorithm taken over from hex2syx.pl
// data stored in a map for uncomplicated overlap checks

hexDumpAddressBlocks.clear();

FileInputStream *inFileStream = inFile.createInputStream();

if( !inFileStream ) {
    statusMessage = T("File doesn't exist!");
    deleteAndZero(inFileStream);
    return false;
}

if( inFileStream->isExhausted() ) {
    statusMessage = T("File is empty!");
    deleteAndZero(inFileStream);
    return false;
}

I hope this fragment could help

SysexToolSend::SysexToolSend(MiosStudio *_miosStudio)
: miosStudio(_miosStudio)
, numBytesToSend(0)
, numBytesSent(0)
, progress(0)
, previousProgress(100)
{
addAndMakeVisible(statusLabel = new Label(T(“Number of Bytes”), String()));
statusLabel->setJustificationType(Justification::right);

addAndMakeVisible(sendBox = new HexTextEditor(statusLabel));

addAndMakeVisible(sendFileChooser = new FilenameComponent (T(“syxfile”),
File::nonexistent,
true, false, false,
“*.syx”,
String(),
T(“(choose a .syx file to send)”)));
sendFileChooser->addListener(this);
sendFileChooser->setBrowseButtonText(T(“Browse”));

addAndMakeVisible(sendStartButton = new TextButton(T("Send Button")));
sendStartButton->setButtonText(T("Send"));
sendStartButton->addListener(this);

Yes, this should be easy to solve, but you might struggle if you’re not familiar with C++.

e.g. in the bit you posted, it’d probably be written like this now:

auto inFileStream = inFile.createInputStream();

if( !inFileStream ) {
    statusMessage = T("File doesn't exist!");
    return false;
}

if( inFileStream->isExhausted() ) {
    statusMessage = T("File is empty!");
    return false;
}

Unfortunately I can’t translate the entire project for you.

Of course :slight_smile:
I am engineer and my last course of C++ was 10 years ago. Maybe the frame have changed a little bit but I will learn.
Thanks you to show me the firsts step.
I will come back when I will make few steps further.
Thanks !