Side-by-side comparison of EEXIST and EISDIR — understand the differences, causes, and fixes.
EEXISTA file creation operation failed because a file with the specified name already exists.
An operation requiring that a file not exist was attempted on an existing file. This occurs with O_CREAT | O_EXCL flags in open(), when calling mkdir() on an existing directory, or creating a symlink where one already exists.
Check if the file exists before creating it. Use O_CREAT without O_EXCL if overwriting is acceptable. Remove the existing file first if appropriate.
EISDIRThe operation is not permitted on a directory, but the target path is a directory.
An attempt was made to perform a file-specific operation (like open for writing or unlink) on a directory.
Use directory-specific operations such as rmdir() or opendir() instead of file operations. To remove a directory and its contents, use rm -r.