~kiwec/ke

ke/src/File.cc -rw-r--r-- 522 bytes
1cc8481d — Wolf Clément Fix compilation 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include "Document.h"
#include "File.h"
#include "Line.h"
#include "Syntax.h"

void File::open() {
	m_text.erase(0, m_text.size());

	FILE* file = fopen(filename.c_str(), "r");
	if(file != NULL) {
		wint_t wc;
		while((wc = fgetwc(file)) != WEOF) {
			m_text.insert((wchar_t*)&wc, 1, m_text.size());
		}
		fclose(file);
	}

	// Update syntax
	Syntax::update(this->m_text);
}

void File::save() {
	FILE* file = fopen(filename.c_str(), "w");
	fputws(&m_text[0], file);
	fclose(file);
	modified = false;
}