Esempio n. 1
0
std::string load_file(const std::string &src)
{
    std::string str;
    FILE *f = fopen(src.c_str(), "rb");
    if (!f)
        throw file_exception(src);
    while (!feof(f))
    {
        char buffer[1024];
        int len = fread(buffer, 1, sizeof(buffer), f);
        if (len < 0)
            throw file_exception(src);
        str += string(buffer, len);
    }
    return str;
}
Esempio n. 2
0
void CFile::Close()
{
//	ASSERT_VALID(this);
	ASSERT(file_ != INVALID_HANDLE_VALUE);

	if (!close_file())
		throw file_exception(); //CFileException::ThrowOsError((LONG)::GetLastError(), m_strFileName);
}
Esempio n. 3
0
/// Sets state \p s and throws depending on the exception setting.
void fstream::set_and_throw (iostate s, const char* op)
{
    if (ios_base::set_and_throw (s))
#if PLATFORM_ANDROID
        printf("file_exception\n");
#else /* !PLATFORM_ANDROID */
	throw file_exception (op, name());
#endif
}
Esempio n. 4
0
/// Get the stat structure.
void fstream::stat (struct stat& rs) const
{
    if (fstat (m_fd, &rs))
#if PLATFORM_ANDROID
        printf("file_exception\n");
#else
	throw file_exception ("stat", name());
#endif
}
Esempio n. 5
0
// Opens the file that we'll write to and gets its FD
void LogBase::openFile() throw (file_exception)
{
    fileDescriptor = open(fileName.c_str(), NEW_FLAG, ALL_PERMISSIONS);

    if (fileDescriptor < 0) {
        throw file_exception(file_exception::CREATE_ERR);
    }

    fileOpen = true;
}
Esempio n. 6
0
/// Attaches to the given \p nfd.
void fstream::attach (int nfd, const char* filename)
{
    assert (filename && "Don't do that");
    clear (goodbit);
    if (nfd < 0 && ios_base::set_and_throw (badbit))
#if PLATFORM_ANDROID
        printf("file exception\n");
#else /* !PLATFORM_ANDROID */
	throw file_exception ("open", filename);
#endif
    close();
    m_fd = nfd;
    m_Filename = filename;
}
Esempio n. 7
0
/// Sets state \p s and throws depending on the exception setting.
void fstream::set_and_throw (iostate s, const char* op)
{
    if (ios_base::set_and_throw (s))
	throw file_exception (op, name());
}
Esempio n. 8
0
/// Get the stat structure.
void fstream::stat (struct stat& rs) const
{
    if (fstat (m_fd, &rs))
	throw file_exception ("stat", name());
}
Esempio n. 9
0
/// Get the stat structure.
void fstream::stat (struct stat& rs) const
{
    if (fstat (m_fd, &rs))
	USTL_THROW(file_exception ("stat", name()));
}