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
2b3ce3ba
Kaydet (Commit)
2b3ce3ba
authored
Ock 26, 2003
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
FSRef and EasyDialogs pathname support was pretty much broken in MacPython-OS9. Fixed.
üst
57c115c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
14 deletions
+68
-14
EasyDialogs.py
Lib/plat-mac/EasyDialogs.py
+16
-12
_Filemodule.c
Mac/Modules/file/_Filemodule.c
+26
-1
filesupport.py
Mac/Modules/file/filesupport.py
+26
-1
No files found.
Lib/plat-mac/EasyDialogs.py
Dosyayı görüntüle @
2b3ce3ba
...
@@ -34,6 +34,7 @@ from Carbon.ControlAccessor import * # Also import Controls constants
...
@@ -34,6 +34,7 @@ from Carbon.ControlAccessor import * # Also import Controls constants
import
Carbon.File
import
Carbon.File
import
macresource
import
macresource
import
os
import
os
import
sys
__all__
=
[
'Message'
,
'AskString'
,
'AskPassword'
,
'AskYesNoCancel'
,
__all__
=
[
'Message'
,
'AskString'
,
'AskPassword'
,
'AskYesNoCancel'
,
'GetArgv'
,
'AskFileForOpen'
,
'AskFileForSave'
,
'AskFolder'
,
'GetArgv'
,
'AskFileForOpen'
,
'AskFileForSave'
,
'AskFolder'
,
...
@@ -635,9 +636,9 @@ def AskFileForOpen(
...
@@ -635,9 +636,9 @@ def AskFileForOpen(
if
issubclass
(
tpwanted
,
Carbon
.
File
.
FSSpec
):
if
issubclass
(
tpwanted
,
Carbon
.
File
.
FSSpec
):
return
tpwanted
(
rr
.
selection
[
0
])
return
tpwanted
(
rr
.
selection
[
0
])
if
issubclass
(
tpwanted
,
str
):
if
issubclass
(
tpwanted
,
str
):
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
FSRefMakePath
())
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
as_pathname
())
if
issubclass
(
tpwanted
,
unicode
):
if
issubclass
(
tpwanted
,
unicode
):
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
FSRefMakePath
(),
'utf8'
)
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
as_pathname
(),
'utf8'
)
raise
TypeError
,
"Unknown value for argument 'wanted':
%
s"
%
repr
(
tpwanted
)
raise
TypeError
,
"Unknown value for argument 'wanted':
%
s"
%
repr
(
tpwanted
)
def
AskFileForSave
(
def
AskFileForSave
(
...
@@ -686,13 +687,16 @@ def AskFileForSave(
...
@@ -686,13 +687,16 @@ def AskFileForSave(
if
issubclass
(
tpwanted
,
Carbon
.
File
.
FSSpec
):
if
issubclass
(
tpwanted
,
Carbon
.
File
.
FSSpec
):
return
tpwanted
(
rr
.
selection
[
0
])
return
tpwanted
(
rr
.
selection
[
0
])
if
issubclass
(
tpwanted
,
(
str
,
unicode
)):
if
issubclass
(
tpwanted
,
(
str
,
unicode
)):
# This is gross, and probably incorrect too
if
sys
.
platform
==
'mac'
:
vrefnum
,
dirid
,
name
=
rr
.
selection
[
0
]
.
as_tuple
()
fullpath
=
rr
.
selection
[
0
]
.
as_pathname
()
pardir_fss
=
Carbon
.
File
.
FSSpec
((
vrefnum
,
dirid
,
''
))
else
:
pardir_fsr
=
Carbon
.
File
.
FSRef
(
pardir_fss
)
# This is gross, and probably incorrect too
pardir_path
=
pardir_fsr
.
FSRefMakePath
()
# This is utf-8
vrefnum
,
dirid
,
name
=
rr
.
selection
[
0
]
.
as_tuple
()
name_utf8
=
unicode
(
name
,
'macroman'
)
.
encode
(
'utf8'
)
pardir_fss
=
Carbon
.
File
.
FSSpec
((
vrefnum
,
dirid
,
''
))
fullpath
=
os
.
path
.
join
(
pardir_path
,
name_utf8
)
pardir_fsr
=
Carbon
.
File
.
FSRef
(
pardir_fss
)
pardir_path
=
pardir_fsr
.
FSRefMakePath
()
# This is utf-8
name_utf8
=
unicode
(
name
,
'macroman'
)
.
encode
(
'utf8'
)
fullpath
=
os
.
path
.
join
(
pardir_path
,
name_utf8
)
if
issubclass
(
tpwanted
,
unicode
):
if
issubclass
(
tpwanted
,
unicode
):
return
unicode
(
fullpath
,
'utf8'
)
return
unicode
(
fullpath
,
'utf8'
)
return
tpwanted
(
fullpath
)
return
tpwanted
(
fullpath
)
...
@@ -741,14 +745,14 @@ def AskFolder(
...
@@ -741,14 +745,14 @@ def AskFolder(
if
issubclass
(
tpwanted
,
Carbon
.
File
.
FSSpec
):
if
issubclass
(
tpwanted
,
Carbon
.
File
.
FSSpec
):
return
tpwanted
(
rr
.
selection
[
0
])
return
tpwanted
(
rr
.
selection
[
0
])
if
issubclass
(
tpwanted
,
str
):
if
issubclass
(
tpwanted
,
str
):
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
FSRefMakePath
())
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
as_pathname
())
if
issubclass
(
tpwanted
,
unicode
):
if
issubclass
(
tpwanted
,
unicode
):
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
FSRefMakePath
(),
'utf8'
)
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
as_pathname
(),
'utf8'
)
raise
TypeError
,
"Unknown value for argument 'wanted':
%
s"
%
repr
(
tpwanted
)
raise
TypeError
,
"Unknown value for argument 'wanted':
%
s"
%
repr
(
tpwanted
)
def
test
():
def
test
():
import
time
,
sys
,
macfs
import
time
,
macfs
Message
(
"Testing EasyDialogs."
)
Message
(
"Testing EasyDialogs."
)
optionlist
=
((
'v'
,
'Verbose'
),
(
'verbose'
,
'Verbose as long option'
),
optionlist
=
((
'v'
,
'Verbose'
),
(
'verbose'
,
'Verbose as long option'
),
...
...
Mac/Modules/file/_Filemodule.c
Dosyayı görüntüle @
2b3ce3ba
...
@@ -1840,7 +1840,26 @@ static PyObject *FSRef_as_pathname(FSRefObject *_self, PyObject *_args)
...
@@ -1840,7 +1840,26 @@ static PyObject *FSRef_as_pathname(FSRefObject *_self, PyObject *_args)
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
#if TARGET_API_MAC_OSX
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
_res
=
FSRef_FSRefMakePath
(
_self
,
_args
);
_res
=
FSRef_FSRefMakePath
(
_self
,
_args
);
#else
char
strbuf
[
1024
];
OSErr
err
;
FSSpec
fss
;
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
if
(
!
PyMac_GetFSSpec
((
PyObject
*
)
_self
,
&
fss
))
return
NULL
;
err
=
PyMac_GetFullPathname
(
&
fss
,
strbuf
,
sizeof
(
strbuf
));
if
(
err
)
{
PyMac_Error
(
err
);
return
NULL
;
}
_res
=
PyString_FromString
(
strbuf
);
#endif
return
_res
;
return
_res
;
}
}
...
@@ -3190,6 +3209,7 @@ int
...
@@ -3190,6 +3209,7 @@ int
PyMac_GetFSRef
(
PyObject
*
v
,
FSRef
*
fsr
)
PyMac_GetFSRef
(
PyObject
*
v
,
FSRef
*
fsr
)
{
{
OSStatus
err
;
OSStatus
err
;
FSSpec
fss
;
if
(
FSRef_Check
(
v
))
{
if
(
FSRef_Check
(
v
))
{
*
fsr
=
((
FSRefObject
*
)
v
)
->
ob_itself
;
*
fsr
=
((
FSRefObject
*
)
v
)
->
ob_itself
;
...
@@ -3208,8 +3228,13 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr)
...
@@ -3208,8 +3228,13 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr)
/* XXXX Should try unicode here too */
/* XXXX Should try unicode here too */
#endif
#endif
/* Otherwise we try to go via an FSSpec */
/* Otherwise we try to go via an FSSpec */
#if TARGET_API_MAC_OSX
if
(
FSSpec_Check
(
v
))
{
if
(
FSSpec_Check
(
v
))
{
if
((
err
=
FSpMakeFSRef
(
&
((
FSSpecObject
*
)
v
)
->
ob_itself
,
fsr
))
==
0
)
fss
=
((
FSSpecObject
*
)
v
)
->
ob_itself
;
#else
if
(
PyMac_GetFSSpec
(
v
,
&
fss
))
{
#endif
if
((
err
=
FSpMakeFSRef
(
&
fss
,
fsr
))
==
0
)
return
1
;
return
1
;
PyMac_Error
(
err
);
PyMac_Error
(
err
);
return
0
;
return
0
;
...
...
Mac/Modules/file/filesupport.py
Dosyayı görüntüle @
2b3ce3ba
...
@@ -271,6 +271,7 @@ int
...
@@ -271,6 +271,7 @@ int
PyMac_GetFSRef(PyObject *v, FSRef *fsr)
PyMac_GetFSRef(PyObject *v, FSRef *fsr)
{
{
OSStatus err;
OSStatus err;
FSSpec fss;
if (FSRef_Check(v)) {
if (FSRef_Check(v)) {
*fsr = ((FSRefObject *)v)->ob_itself;
*fsr = ((FSRefObject *)v)->ob_itself;
...
@@ -289,8 +290,13 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr)
...
@@ -289,8 +290,13 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr)
/* XXXX Should try unicode here too */
/* XXXX Should try unicode here too */
#endif
#endif
/* Otherwise we try to go via an FSSpec */
/* Otherwise we try to go via an FSSpec */
#if TARGET_API_MAC_OSX
if (FSSpec_Check(v)) {
if (FSSpec_Check(v)) {
if ((err=FSpMakeFSRef(&((FSSpecObject *)v)->ob_itself, fsr)) == 0)
fss = ((FSSpecObject *)v)->ob_itself;
#else
if (PyMac_GetFSSpec(v, &fss)) {
#endif
if ((err=FSpMakeFSRef(&fss, fsr)) == 0)
return 1;
return 1;
PyMac_Error(err);
PyMac_Error(err);
return 0;
return 0;
...
@@ -808,7 +814,26 @@ f.docstring = lambda: "() -> string"
...
@@ -808,7 +814,26 @@ f.docstring = lambda: "() -> string"
fsref_methods
.
append
(
f
)
fsref_methods
.
append
(
f
)
FSRef_as_pathname_body
=
"""
FSRef_as_pathname_body
=
"""
#if TARGET_API_MAC_OSX
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_res = FSRef_FSRefMakePath(_self, _args);
_res = FSRef_FSRefMakePath(_self, _args);
#else
char strbuf[1024];
OSErr err;
FSSpec fss;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
if ( !PyMac_GetFSSpec((PyObject *)_self, &fss))
return NULL;
err = PyMac_GetFullPathname(&fss, strbuf, sizeof(strbuf));
if ( err ) {
PyMac_Error(err);
return NULL;
}
_res = PyString_FromString(strbuf);
#endif
return _res;
return _res;
"""
"""
f
=
ManualGenerator
(
"as_pathname"
,
FSRef_as_pathname_body
)
f
=
ManualGenerator
(
"as_pathname"
,
FSRef_as_pathname_body
)
...
...
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