glibmm 2.80.0
Public Types | Public Member Functions | List of all members
Glib::FileError Class Reference

Exception class for file-related errors. More...

#include <glibmm/fileutils.h>

Inheritance diagram for Glib::FileError:
Inheritance graph
[legend]

Public Types

enum  Code {
  EXISTS ,
  IS_DIRECTORY ,
  ACCESS_DENIED ,
  NAME_TOO_LONG ,
  NO_SUCH_ENTITY ,
  NOT_DIRECTORY ,
  NO_SUCH_DEVICE ,
  NOT_DEVICE ,
  READONLY_FILESYSTEM ,
  TEXT_FILE_BUSY ,
  FAULTY_ADDRESS ,
  SYMLINK_LOOP ,
  NO_SPACE_LEFT ,
  NOT_ENOUGH_MEMORY ,
  TOO_MANY_OPEN_FILES ,
  FILE_TABLE_OVERFLOW ,
  BAD_FILE_DESCRIPTOR ,
  INVALID_ARGUMENT ,
  BROKEN_PIPE ,
  TRYAGAIN ,
  INTERRUPTED ,
  IO_ERROR ,
  NOT_OWNER ,
  NOSYS ,
  FAILED
}
 Values corresponding to errno codes returned from file operations on UNIX. More...
 

Public Member Functions

 FileError (Code error_code, const Glib::ustring &error_message)
 
 FileError (GError *gobject)
 
Code code () const
 
- Public Member Functions inherited from Glib::Error
 Error ()
 
 Error (GQuark error_domain, int error_code, const Glib::ustring & message)
 
 Error (GError *gobject, bool take_copy=false)
 
 Error (const Error &other)
 
Erroroperator= (const Error &other)
 
 ~Error () noexcept override
 
 operator bool () const
 Test whether the Error has an underlying instance.
 
GQuark domain () const
 
int code () const
 
const charwhat () const noexcept override
 
bool matches (GQuark error_domain, int error_code) const
 
GErrorgobj ()
 
const GErrorgobj () const
 

Additional Inherited Members

- Protected Attributes inherited from Glib::Error
GErrorgobject_
 

Detailed Description

Exception class for file-related errors.

Member Enumeration Documentation

◆ Code

Values corresponding to errno codes returned from file operations on UNIX.

Unlike errno codes, GFileError values are available on all systems, even Windows. The exact meaning of each code depends on what sort of file operation you were performing; the UNIX documentation gives more details. The following error code descriptions come from the GNU C Library manual, and are under the copyright of that manual.

It's not very portable to make detailed assumptions about exactly which errors will be returned from a given operation. Some errors don't occur on some systems, etc., sometimes there are subtle differences in when a system will report a given error, etc.

Enumerator
EXISTS 

Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation.

(EEXIST)

IS_DIRECTORY 

File is a directory; you cannot open a directory for writing, or create or remove hard links to it.

(EISDIR)

ACCESS_DENIED 

Permission denied; the file permissions do not allow the attempted operation.

(EACCES)

NAME_TOO_LONG 

Filename too long.

(ENAMETOOLONG)

NO_SUCH_ENTITY 

No such file or directory.

(ENOENT)

This is a "file doesn't exist" error for ordinary files that are referenced in contexts where they are expected to already exist.

NOT_DIRECTORY 

A file that isn't a directory was specified when a directory is required.

(ENOTDIR)

NO_SUCH_DEVICE 

No such device or address.

(ENXIO)

The system tried to use the device represented by a file you specified, and it couldn't find the device. This can mean that the device file was installed incorrectly, or that the physical device is missing or not correctly attached to the computer.

NOT_DEVICE 

The underlying file system of the specified file does not support memory mapping.

(ENODEV)

READONLY_FILESYSTEM 

The directory containing the new link can't be modified because it's on a read-only file system.

(EROFS)

TEXT_FILE_BUSY 

Text file busy.

(ETXTBSY)

FAULTY_ADDRESS 

You passed in a pointer to bad memory.

(EFAULT)

(GLib won't reliably return this, don't pass in pointers to bad memory.).

SYMLINK_LOOP 

Too many levels of symbolic links were encountered in looking up a file name.

(ELOOP)

This often indicates a cycle of symbolic links.

NO_SPACE_LEFT 

No space left on device; write operation on a file failed because the disk is full.

(ENOSPC)

NOT_ENOUGH_MEMORY 

No memory available.

(ENOMEM)

The system cannot allocate more virtual memory because its capacity is full.

TOO_MANY_OPEN_FILES 

The current process has too many files open and can't open any more.

(EMFILE)

Duplicate descriptors do count toward this limit.

FILE_TABLE_OVERFLOW 

There are too many distinct file openings in the entire system.

(ENFILE)

BAD_FILE_DESCRIPTOR 

Bad file descriptor; for example, I/O on a descriptor that has been closed or reading from a descriptor open only for writing (or vice versa).

(EBADF)

INVALID_ARGUMENT 

Invalid argument.

(EINVAL)

This is used to indicate various kinds of problems with passing the wrong argument to a library function.

BROKEN_PIPE 

Broken pipe; there is no process reading from the other end of a pipe.

(EPIPE)

Every library function that returns this error code also generates a 'SIGPIPE' signal; this signal terminates the program if not handled or blocked. Thus, your program will never actually see this code unless it has handled or blocked 'SIGPIPE'.

TRYAGAIN 

Resource temporarily unavailable; the call might work if you try again later.

(EAGAIN)

We use TRYAGAIN instead of TRY_AGAIN, because that is defined as a macro by a Unix header.

INTERRUPTED 

Interrupted function call; an asynchronous signal occurred and prevented completion of the call.

(EINTR)

When this happens, you should try the call again.

IO_ERROR 

Input/output error; usually used for physical read or write errors.

(EIO)

i.e. the disk or other physical device hardware is returning errors.

NOT_OWNER 

Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation.

(EPERM)

NOSYS 

Function not implemented; this indicates that the system is missing some functionality.

FAILED 

Does not correspond to a UNIX error code; this is the standard "failed for unspecified reason" error code present in all Error error code enumerations.

Returned if no specific code applies.

Constructor & Destructor Documentation

◆ FileError() [1/2]

Glib::FileError::FileError ( Code  error_code,
const Glib::ustring error_message 
)

◆ FileError() [2/2]

Glib::FileError::FileError ( GError gobject)
explicit

Member Function Documentation

◆ code()

Code Glib::FileError::code ( ) const