+Handle STATUS_SHARING_VIOLATION.
[captive.git] / src / libcaptive / client / result.c
1 /* $Id$
2  * captive vfs result code translation for Gnome-VFS-2.0
3  * Copyright (C) 2002-2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "result.h"     /* self */
23 #include <glib/gmessages.h>
24 #include "reactos/ddk/status.h" /* for STATUS_* */
25 #include <libgnomevfs/gnome-vfs-result.h>       /* for GnomeVFSResult */
26
27
28 GnomeVFSResult captive_NTSTATUS_to_GnomeVFSResult(NTSTATUS err)
29 {
30         switch (err) {
31                 case STATUS_NO_SUCH_FILE:          return GNOME_VFS_ERROR_EOF;  /* ==0 files found */
32                 case STATUS_NO_MORE_FILES:         return GNOME_VFS_ERROR_EOF;  /* >=1 files found */
33                 case STATUS_OBJECT_NAME_COLLISION: return GNOME_VFS_ERROR_FILE_EXISTS;
34                 case STATUS_OBJECT_NAME_NOT_FOUND: return GNOME_VFS_ERROR_NOT_FOUND;
35                 case STATUS_UNRECOGNIZED_VOLUME:   return GNOME_VFS_ERROR_WRONG_FORMAT;
36                 case STATUS_OBJECT_NAME_INVALID:   return GNOME_VFS_ERROR_INVALID_URI;
37                 case STATUS_DIRECTORY_NOT_EMPTY:   return GNOME_VFS_ERROR_DIRECTORY_NOT_EMPTY;
38                 case STATUS_NOT_A_DIRECTORY:       return GNOME_VFS_ERROR_NOT_A_DIRECTORY;
39                 case STATUS_INVALID_PARAMETER:     return GNOME_VFS_ERROR_BAD_PARAMETERS;       /* read() of directory handle */
40                 case STATUS_CANNOT_DELETE:         return GNOME_VFS_ERROR_GENERIC;      /* unlink() of '/' */
41                 case STATUS_ACCESS_DENIED:         return GNOME_VFS_ERROR_ACCESS_DENIED;        /* mkdir() on r/o device */
42                 case STATUS_OBJECT_PATH_NOT_FOUND: return GNOME_VFS_ERROR_NOT_FOUND;    /* rename() to nonexist/smth */
43                 case STATUS_MEDIA_WRITE_PROTECTED: return GNOME_VFS_ERROR_READ_ONLY;
44                 case STATUS_SHARING_VIOLATION:     return GNOME_VFS_ERROR_DIRECTORY_BUSY;       /* errno EBUSY */
45                 default:; /* PASSTHRU */
46                 }
47         return GNOME_VFS_OK;    /* undetected */
48 }