Thread: Basic file io
View Single Post
Old 04-07-2017, 04:40 PM   #9
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by Xenakios View Post
Code:
        WDL_FileWrite outfile("C:\\ssd_tests\\wdl_test_file.txt");
        if (outfile.IsOpen()==true)
        {
            std::string txt1("Foo\n");
            outfile.Write(txt1.data(),txt1.size());
            std::string txt2("Bar\n");
            outfile.Write(txt2.data(),txt2.size());
        } else std::cout << "could not open file for writing\n";
How would I use this to write a file to Reaper's resource path ?

I've tried
Code:
char buf[1024];
strcpy(buf, GetResourcePath());
strcpy(buf, "wdl_test_file.txt");
WDL_FileWrite outfile(buf); 

if (outfile.IsOpen() == true)
....
It kinda half-works, i.e. a file is written, but it's not in Reaper's resource path.
I guess my non-knowledge about C strings comes to light again here...

edit:
Forgot to mention, this is in SWS extensions, so GetResourcePath() works, I can see when I set a breakpoint, I'm having trouble with the string concatenation obviously.

Last edited by nofish; 04-07-2017 at 05:00 PM.
nofish is offline   Reply With Quote