Example #1
0
int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const {

	int i = 0;
	for (i = 0; i < p_length && !eof_reached(); i++)
		p_dst[i] = get_8();

	return i;
}
Example #2
0
Error FileAccessZip::get_error() const {

	if (!zfile) {

		return ERR_UNCONFIGURED;
	};
	if (eof_reached()) {
		return ERR_FILE_EOF;
	};

	return OK;
};
Example #3
0
Vector<String> FileAccess::get_csv_line(String delim) const {

	ERR_FAIL_COND_V(delim.length() != 1, Vector<String>());

	String l;
	int qc = 0;
	do {
		ERR_FAIL_COND_V(eof_reached(), Vector<String>());

		l += get_line() + "\n";
		qc = 0;
		for (int i = 0; i < l.length(); i++) {

			if (l[i] == '"')
				qc++;
		}

	} while (qc % 2);

	l = l.substr(0, l.length() - 1);

	Vector<String> strings;

	bool in_quote = false;
	String current;
	for (int i = 0; i < l.length(); i++) {

		CharType c = l[i];
		CharType s[2] = { 0, 0 };

		if (!in_quote && c == delim[0]) {
			strings.push_back(current);
			current = String();
		} else if (c == '"') {
			if (l[i + 1] == '"') {
				s[0] = '"';
				current += s;
				i++;
			} else {

				in_quote = !in_quote;
			}
		} else {
			s[0] = c;
			current += s;
		}
	}

	strings.push_back(current);

	return strings;
}
Example #4
0
String _File::get_as_text() const {

    String text;
    String l = get_line();
    while(!eof_reached()) {
        text+=l+"\n";
        l = get_line();
    }
    text+=l;

    return text;


}
Example #5
0
String FileAccess::get_line() const {

	CharBuffer line;

	CharType c = get_8();

	while (!eof_reached()) {

		if (c == '\n' || c == '\0') {
			line.push_back(0);
			return String::utf8(line.get_data());
		} else if (c != '\r')
			line.push_back(c);

		c = get_8();
	}
	line.push_back(0);
	return String::utf8(line.get_data());
}
Example #6
0
String FileAccess::get_token() const {

	CharString token;

	CharType c = get_8();

	while (!eof_reached()) {

		if (c <= ' ') {
			if (token.length())
				break;
		} else {
			token += c;
		}
		c = get_8();
	}

	return String::utf8(token.get_data());
}
Example #7
0
String FileAccess::get_token() const {

	CharString token;

	CharType c = get_8();

	while (!eof_reached()) {

		if (c <= ' ') {
			if (!token.empty())
				break;
		} else {
			token.push_back(c);
		}
		c = get_8();
	}

	token.push_back(0);
	return String::utf8(token.get_data());
}
Error FileAccessJAndroid::get_error() const {

	if (eof_reached())
		return ERR_FILE_EOF;
	return OK;
}