Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
5cc6d6e5
Kaydet (Commit)
5cc6d6e5
authored
Kas 06, 2001
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Changed names, added bridge functions to macfs.fsref objects and
generally did things to get it working.
üst
2bf52dae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
67 deletions
+48
-67
hfsplusmodule.c
Mac/Modules/hfsplusmodule.c
+48
-67
No files found.
Mac/Modules/hfsplusmodule.c
Dosyayı görüntüle @
5cc6d6e5
/*
/*
$Log$
** Interface to hfs+ API.
Revision 1.2 2001/11/06 12:06:39 jackjansen
** Contributed by Nitin Ganatra.
First couple of fixes to make it compile with Universal 3.3.2.
Revision 1.8 2001/10/03 17:29:01 ganatra
add parent method to FSRef class
Revision 1.7 2001/04/13 20:54:19 ganatra
More standard format for MacOSError exceptions
Revision 1.6 2001/04/11 04:07:40 ganatra
Add permissions constants and log header..
*/
*/
#include "Python.h"
#include "Python.h"
#include "pymactoolbox.h"
#ifdef WITHOUT_FRAMEWORKS
#ifdef WITHOUT_FRAMEWORKS
#include <Files.h>
#include <Files.h>
#else
#else
...
@@ -672,6 +662,19 @@ PyObject *fsRefObject_parent(fsRefObject *self, PyObject *args)
...
@@ -672,6 +662,19 @@ PyObject *fsRefObject_parent(fsRefObject *self, PyObject *args)
return
(
PyObject
*
)
newObject
;
return
(
PyObject
*
)
newObject
;
}
}
//__________________________________________________________________________________________________
static
char
fsRefObject_as_fsref__doc__
[]
=
"as_fsref() -> macfs.fsref
\n\n
\
Return a macfs.fsref-style object from an hfsplus.fsref style object"
;
static
PyObject
*
fsRefObject_as_fsref
(
fsRefObject
*
self
,
PyObject
*
args
)
{
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
PyMac_BuildFSRef
(
&
self
->
ref
);
}
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________
static
char
fsRefObject_openfork__doc__
[]
=
static
char
fsRefObject_openfork__doc__
[]
=
"openfork([resourcefork [,perms]]) -> forkRef
\n\n
\
"openfork([resourcefork [,perms]]) -> forkRef
\n\n
\
...
@@ -975,6 +978,7 @@ static PyMethodDef fsRefObject_methods[] = {
...
@@ -975,6 +978,7 @@ static PyMethodDef fsRefObject_methods[] = {
{
"opendir"
,
(
PyCFunction
)
fsRefObject_opendir
,
METH_VARARGS
,
fsRefObject_opendir__doc__
},
{
"opendir"
,
(
PyCFunction
)
fsRefObject_opendir
,
METH_VARARGS
,
fsRefObject_opendir__doc__
},
{
"openfork"
,
(
PyCFunction
)
fsRefObject_openfork
,
METH_VARARGS
,
fsRefObject_openfork__doc__
},
{
"openfork"
,
(
PyCFunction
)
fsRefObject_openfork
,
METH_VARARGS
,
fsRefObject_openfork__doc__
},
{
"as_fsref"
,
(
PyCFunction
)
fsRefObject_as_fsref
,
METH_VARARGS
,
fsRefObject_as_fsref__doc__
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -1041,7 +1045,7 @@ statichere PyTypeObject fsRefObject_Type = {
...
@@ -1041,7 +1045,7 @@ statichere PyTypeObject fsRefObject_Type = {
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________
//____________________________________ MODULE FUNCTIONS ____________________________________________
//____________________________________ MODULE FUNCTIONS ____________________________________________
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________
static
char
fmgr
module_getcatinfo__doc__
[]
=
static
char
hfsplus
module_getcatinfo__doc__
[]
=
"getcatinfo(path[,bitmap]) -> Dict
\n\n
\
"getcatinfo(path[,bitmap]) -> Dict
\n\n
\
Returns a dictionary of attributes for the given item
\n
\
Returns a dictionary of attributes for the given item
\n
\
and an optional bitmap describing the attributes to be
\n
\
and an optional bitmap describing the attributes to be
\n
\
...
@@ -1049,9 +1053,8 @@ fetched (see CarbonCore/Files.h for details of the bit\n\
...
@@ -1049,9 +1053,8 @@ fetched (see CarbonCore/Files.h for details of the bit\n\
definitions and key definitions)."
;
definitions and key definitions)."
;
static
static
PyObject
*
fmgr
module_getcatinfo
(
PyObject
*
self
,
PyObject
*
args
)
PyObject
*
hfsplus
module_getcatinfo
(
PyObject
*
self
,
PyObject
*
args
)
{
{
char
*
path
;
PyObject
*
dict
;
PyObject
*
dict
;
FSRef
ref
;
FSRef
ref
;
OSErr
err
;
OSErr
err
;
...
@@ -1059,20 +1062,14 @@ PyObject *fmgrmodule_getcatinfo(PyObject *self, PyObject *args)
...
@@ -1059,20 +1062,14 @@ PyObject *fmgrmodule_getcatinfo(PyObject *self, PyObject *args)
HFSUniStr255
uni
;
HFSUniStr255
uni
;
FSCatalogInfoBitmap
bitmap
=
kFSCatInfoGettableInfo
;
FSCatalogInfoBitmap
bitmap
=
kFSCatInfoGettableInfo
;
if
(
!
PyArg_ParseTuple
(
args
,
"
s|l"
,
&
path
,
&
bitmap
))
if
(
!
PyArg_ParseTuple
(
args
,
"
O&|l"
,
PyMac_GetFSRef
,
&
ref
,
&
bitmap
))
return
NULL
;
return
NULL
;
Py_BEGIN_ALLOW_THREADS
err
=
FSPathMakeRef
((
UInt8
*
)
path
,
&
ref
,
NULL
);
Py_END_ALLOW_THREADS
if
(
err
!=
noErr
)
return
macos_error_for_call
(
err
,
"FSPathMakeRef"
,
path
);
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
err
=
FSGetCatalogInfo
(
&
ref
,
bitmap
,
&
info
,
&
uni
,
NULL
,
NULL
);
err
=
FSGetCatalogInfo
(
&
ref
,
bitmap
,
&
info
,
&
uni
,
NULL
,
NULL
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
if
(
err
!=
noErr
)
if
(
err
!=
noErr
)
return
macos_error_for_call
(
err
,
"FSGetCatalogInfo"
,
path
);
return
macos_error_for_call
(
err
,
"FSGetCatalogInfo"
,
NULL
);
dict
=
dict_from_cataloginfo
(
bitmap
,
&
info
,
&
uni
);
dict
=
dict_from_cataloginfo
(
bitmap
,
&
info
,
&
uni
);
if
(
dict
==
NULL
)
if
(
dict
==
NULL
)
...
@@ -1083,30 +1080,27 @@ PyObject *fmgrmodule_getcatinfo(PyObject *self, PyObject *args)
...
@@ -1083,30 +1080,27 @@ PyObject *fmgrmodule_getcatinfo(PyObject *self, PyObject *args)
}
}
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________
static
char
fmgr
module_opendir__doc__
[]
=
static
char
hfsplus
module_opendir__doc__
[]
=
"opendir(path) -> iterator
\n\n
\
"opendir(path) -> iterator
\n\n
\
Return an iterator for listdir."
;
Return an iterator for listdir."
;
static
static
PyObject
*
fmgr
module_opendir
(
PyObject
*
self
,
PyObject
*
args
)
PyObject
*
hfsplus
module_opendir
(
PyObject
*
self
,
PyObject
*
args
)
{
{
char
*
path
;
iteratorObject
*
rv
;
iteratorObject
*
rv
;
FSRef
ref
;
FSRef
ref
;
OSErr
err
;
OSErr
err
;
#if 0
Boolean isdir;
Boolean isdir;
#endif
if
(
!
PyArg_ParseTuple
(
args
,
"
s"
,
&
path
))
if
(
!
PyArg_ParseTuple
(
args
,
"
O&"
,
PyMac_GetFSRef
,
&
ref
))
return
NULL
;
return
NULL
;
Py_BEGIN_ALLOW_THREADS
#if 0
err
=
FSPathMakeRef
((
UInt8
*
)
path
,
&
ref
,
&
isdir
);
if (isdir == false)
Py_END_ALLOW_THREADS
if
(
err
!=
noErr
)
return
macos_error_for_call
(
err
,
"FSPathMakeRef"
,
path
);
else
if
(
isdir
==
false
)
return PyErr_Format(PyExc_SyntaxError, "requires a directory");
return PyErr_Format(PyExc_SyntaxError, "requires a directory");
#endif
rv
=
newIteratorObject
(
args
,
&
ref
);
rv
=
newIteratorObject
(
args
,
&
ref
);
if
(
rv
==
NULL
)
if
(
rv
==
NULL
)
...
@@ -1115,29 +1109,20 @@ PyObject *fmgrmodule_opendir(PyObject *self, PyObject *args)
...
@@ -1115,29 +1109,20 @@ PyObject *fmgrmodule_opendir(PyObject *self, PyObject *args)
}
}
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________
static
char
fmgr
module_fsref__doc__
[]
=
static
char
hfsplus
module_fsref__doc__
[]
=
"fsref(path) -> FSRef
\n\n
\
"fsref(path) -> FSRef
\n\n
\
Return an FSRef object."
;
Return an FSRef object."
;
static
static
PyObject
*
fmgr
module_fsref
(
PyObject
*
self
,
PyObject
*
args
)
PyObject
*
hfsplus
module_fsref
(
PyObject
*
self
,
PyObject
*
args
)
{
{
char
*
path
;
fsRefObject
*
obj
;
fsRefObject
*
obj
;
FSRef
ref
;
FSRef
ref
;
OSErr
err
;
Boolean
isdir
=
0
;
Boolean
isdir
;
if
(
!
PyArg_ParseTuple
(
args
,
"
s"
,
&
path
))
if
(
!
PyArg_ParseTuple
(
args
,
"
O&"
,
PyMac_GetFSRef
,
&
ref
))
return
NULL
;
return
NULL
;
Py_BEGIN_ALLOW_THREADS
err
=
FSPathMakeRef
((
UInt8
*
)
path
,
&
ref
,
&
isdir
);
Py_END_ALLOW_THREADS
if
(
err
!=
noErr
)
return
macos_error_for_call
(
err
,
"FSPathMakeRef"
,
path
);
obj
=
newFSRefObject
(
args
,
&
ref
,
true
,
isdir
);
obj
=
newFSRefObject
(
args
,
&
ref
,
true
,
isdir
);
if
(
obj
==
NULL
)
if
(
obj
==
NULL
)
return
NULL
;
return
NULL
;
...
@@ -1145,7 +1130,7 @@ PyObject *fmgrmodule_fsref(PyObject *self, PyObject *args)
...
@@ -1145,7 +1130,7 @@ PyObject *fmgrmodule_fsref(PyObject *self, PyObject *args)
}
}
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________
static
char
fmgr
module_openfork__doc__
[]
=
static
char
hfsplus
module_openfork__doc__
[]
=
"openfork(path[,resourcefork[,perms]]) -> forkRef
\n\n
\
"openfork(path[,resourcefork[,perms]]) -> forkRef
\n\n
\
Return a forkRef object for reading/writing/etc. Optionally,
\n
\
Return a forkRef object for reading/writing/etc. Optionally,
\n
\
pass 1 for the resourcefork param to open the resource fork,
\n
\
pass 1 for the resourcefork param to open the resource fork,
\n
\
...
@@ -1157,27 +1142,23 @@ and permissions to open read-write or something else:\n\
...
@@ -1157,27 +1142,23 @@ and permissions to open read-write or something else:\n\
4: fsRdWrShPerm"
;
4: fsRdWrShPerm"
;
static
static
PyObject
*
fmgr
module_openfork
(
PyObject
*
self
,
PyObject
*
args
)
PyObject
*
hfsplus
module_openfork
(
PyObject
*
self
,
PyObject
*
args
)
{
{
char
*
path
;
forkRefObject
*
rv
;
forkRefObject
*
rv
;
FSRef
ref
;
FSRef
ref
;
OSErr
err
;
#if 0
Boolean isdir;
Boolean isdir;
#endif
int
resfork
=
0
,
perms
=
fsRdPerm
;
int
resfork
=
0
,
perms
=
fsRdPerm
;
if
(
!
PyArg_ParseTuple
(
args
,
"s|ii"
,
&
path
,
&
resfork
,
&
perms
))
if
(
!
PyArg_ParseTuple
(
args
,
"s|ii"
,
PyMac_GetFSRef
,
&
ref
,
&
resfork
,
&
perms
))
return
NULL
;
return
NULL
;
Py_BEGIN_ALLOW_THREADS
#if 0
err
=
FSPathMakeRef
((
UInt8
*
)
path
,
&
ref
,
&
isdir
);
if (isdir == true) {
Py_END_ALLOW_THREADS
if
(
err
!=
noErr
)
{
return
macos_error_for_call
(
err
,
"FSPathMakeRef"
,
path
);
}
else
if
(
isdir
==
true
)
{
return PyErr_Format(PyExc_SyntaxError, "requires a file");
return PyErr_Format(PyExc_SyntaxError, "requires a file");
}
}
#endif
rv
=
newForkRefObject
(
args
,
&
ref
,
resfork
,
perms
);
rv
=
newForkRefObject
(
args
,
&
ref
,
resfork
,
perms
);
if
(
rv
==
NULL
)
if
(
rv
==
NULL
)
...
@@ -1188,11 +1169,11 @@ PyObject *fmgrmodule_openfork(PyObject *self, PyObject *args)
...
@@ -1188,11 +1169,11 @@ PyObject *fmgrmodule_openfork(PyObject *self, PyObject *args)
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________
// List of functions defined in the module
// List of functions defined in the module
//
//
static
PyMethodDef
fmgr
module_methods
[]
=
{
static
PyMethodDef
hfsplus
module_methods
[]
=
{
{
"getcatinfo"
,
fmgrmodule_getcatinfo
,
METH_VARARGS
,
fmgr
module_getcatinfo__doc__
},
{
"getcatinfo"
,
hfsplusmodule_getcatinfo
,
METH_VARARGS
,
hfsplus
module_getcatinfo__doc__
},
{
"opendir"
,
fmgrmodule_opendir
,
METH_VARARGS
,
fmgr
module_opendir__doc__
},
{
"opendir"
,
hfsplusmodule_opendir
,
METH_VARARGS
,
hfsplus
module_opendir__doc__
},
{
"openfork"
,
fmgrmodule_openfork
,
METH_VARARGS
,
fmgr
module_openfork__doc__
},
{
"openfork"
,
hfsplusmodule_openfork
,
METH_VARARGS
,
hfsplus
module_openfork__doc__
},
{
"fsref"
,
fmgrmodule_fsref
,
METH_VARARGS
,
fmgr
module_fsref__doc__
},
{
"fsref"
,
hfsplusmodule_fsref
,
METH_VARARGS
,
hfsplus
module_fsref__doc__
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -1211,7 +1192,7 @@ inithfsplus(void)
...
@@ -1211,7 +1192,7 @@ inithfsplus(void)
fsRefObject_Type
.
ob_type
=
&
PyType_Type
;
fsRefObject_Type
.
ob_type
=
&
PyType_Type
;
/* Create the module and add the functions */
/* Create the module and add the functions */
m
=
Py_InitModule
(
"
fmgr"
,
fmgr
module_methods
);
m
=
Py_InitModule
(
"
hfsplus"
,
hfsplus
module_methods
);
/* Add some symbolic constants to the module */
/* Add some symbolic constants to the module */
d
=
PyModule_GetDict
(
m
);
d
=
PyModule_GetDict
(
m
);
...
@@ -1225,7 +1206,7 @@ inithfsplus(void)
...
@@ -1225,7 +1206,7 @@ inithfsplus(void)
insert_int
(
d
,
"fsFromLEOF"
,
fsFromLEOF
);
insert_int
(
d
,
"fsFromLEOF"
,
fsFromLEOF
);
insert_int
(
d
,
"fsFromMark"
,
fsFromMark
);
insert_int
(
d
,
"fsFromMark"
,
fsFromMark
);
insert_int
(
d
,
"noCacheMask"
,
noCacheMask
);
insert_int
(
d
,
"noCacheMask"
,
noCacheMask
);
ErrorObject
=
PyErr_NewException
(
"
fmgr
.error"
,
NULL
,
NULL
);
ErrorObject
=
PyErr_NewException
(
"
hfsplus
.error"
,
NULL
,
NULL
);
PyDict_SetItemString
(
d
,
"error"
,
ErrorObject
);
PyDict_SetItemString
(
d
,
"error"
,
ErrorObject
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment