Changeset 36 for trunk/pymigemo
- Timestamp:
- 11/07/10 01:36:30 (14 years ago)
- Location:
- trunk/pymigemo
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pymigemo/ChangeLog
- Property svn:keywords set to Id
r34 r36 1 2010-11-07 Atzm WATANABE <atzm@atzm.org> 2 3 * pymigemo.c (isloadable): check dictionary loadable 4 1 5 2010-11-06 Atzm WATANABE <atzm@atzm.org> 2 6 … … 23 27 24 28 * initial 29 30 $Id$ -
trunk/pymigemo/LICENSE
r30 r36 1 Copyright (c) 2005-20 09, Atzm WATANABE <atzm@atzm.org>1 Copyright (c) 2005-2010, Atzm WATANABE <atzm@atzm.org> 2 2 All rights reserved. 3 3 -
trunk/pymigemo/pymigemo.c
r35 r36 11 11 #include <stdbool.h> 12 12 #include <string.h> 13 #include <errno.h> 14 #include <sys/types.h> 15 #include <sys/stat.h> 16 #include <fcntl.h> 17 #include <unistd.h> 13 18 14 19 #define PYMIGEMO_VERSION "0.3" … … 60 65 } 61 66 67 static int 68 isloadable(const char *path) 69 { 70 struct stat st; 71 int ret = 0; 72 int fd = open(path, O_RDONLY); 73 74 if (fd < 0) { 75 return errno; 76 } 77 78 if (fstat(fd, &st) < 0) { 79 ret = errno; 80 goto isloadable_end; 81 } 82 if (S_ISDIR(st.st_mode)) { 83 ret = EISDIR; 84 goto isloadable_end; 85 } 86 87 isloadable_end: 88 if (close(fd) < 0) { 89 ret = errno; 90 } 91 return ret; 92 } 93 62 94 static void 63 95 Migemo_dealloc(Migemo *self) … … 97 129 98 130 if (dictionary) { 131 int ret = isloadable(dictionary); 132 133 if (ret != 0) { 134 PyErr_SetString(PyExc_ValueError, strerror(ret)); 135 return -1; 136 } 137 99 138 if (self->migemo_obj) { 100 139 migemo_close(self->migemo_obj); … … 241 280 242 281 if (dict_file) { 282 int ret = isloadable(dict_file); 283 284 if (ret != 0) { 285 PyErr_SetString(PyExc_ValueError, strerror(ret)); 286 return NULL; 287 } 288 243 289 result = PyInt_FromLong((long)migemo_load(self->migemo_obj, dict_id, dict_file)); 244 290 } -
trunk/pymigemo/setup.py
r31 r36 1 1 #!/usr/bin/env python 2 # -*- coding: ascii -*- 2 # -*- coding: utf-8 -*- 3 # $Id$ 3 4 4 5 from distutils.core import setup, Extension 5 6 setup(name="migemo", 6 version="0. 2",7 version="0.3", 7 8 description="C/Migemo wrapper for Python", 8 9 author="Atzm WATANABE",
Note: See TracChangeset
for help on using the changeset viewer.