Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 914 Bytes

file.md

File metadata and controls

58 lines (42 loc) · 914 Bytes

File Management

  • File: Universal file handler.

Usage

  • Write text to file
#include <Caitlyn/File>

using namespace Caitlyn;

int main()
{
    const String some = "Lorem ipsum dolor sit amet,";
    const String other = "consectetur adipiscing elit...";
    const String unicode = "Hello, 世界!";

    auto file = MakeFile("somefile.txt");
    file.Write("{} {}\n{}", some, other, unicode);
    file.Close();
  
    return 0;
}
  • File (somefile.txt)
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
Hello, 世界!
  • Read lines from file
#include <Caitlyn/IO>

using namespace Caitlyn;

int main()
{
    auto file = MakeFile("somefile.txt");
    
    while (file)
    {
        OutputStream::WriteLine("{}", file.ReadLine());
    }
    file.Close();
    return 0;
}
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
Hello, 世界!