512 PyMem_Free(name); |
512 PyMem_Free(name); |
513 return file_obj; |
513 return file_obj; |
514 } |
514 } |
515 #endif |
515 #endif |
516 |
516 |
|
517 #ifdef __APPLE__ |
|
518 #import <ApplicationServices/ApplicationServices.h> |
|
519 |
|
520 static PyObject *isgui(PyObject *self) |
|
521 { |
|
522 CFDictionaryRef dict = CGSessionCopyCurrentDictionary(); |
|
523 |
|
524 if (dict != NULL) { |
|
525 CFRelease(dict); |
|
526 return Py_True; |
|
527 } else { |
|
528 return Py_False; |
|
529 } |
|
530 } |
|
531 #endif |
|
532 |
517 static char osutil_doc[] = "Native operating system services."; |
533 static char osutil_doc[] = "Native operating system services."; |
518 |
534 |
519 static PyMethodDef methods[] = { |
535 static PyMethodDef methods[] = { |
520 {"listdir", (PyCFunction)listdir, METH_VARARGS | METH_KEYWORDS, |
536 {"listdir", (PyCFunction)listdir, METH_VARARGS | METH_KEYWORDS, |
521 "list a directory\n"}, |
537 "list a directory\n"}, |
522 #ifdef _WIN32 |
538 #ifdef _WIN32 |
523 {"posixfile", (PyCFunction)posixfile, METH_VARARGS | METH_KEYWORDS, |
539 {"posixfile", (PyCFunction)posixfile, METH_VARARGS | METH_KEYWORDS, |
524 "Open a file with POSIX-like semantics.\n" |
540 "Open a file with POSIX-like semantics.\n" |
525 "On error, this function may raise either a WindowsError or an IOError."}, |
541 "On error, this function may raise either a WindowsError or an IOError."}, |
526 #endif |
542 #endif |
|
543 #ifdef __APPLE__ |
|
544 { |
|
545 "isgui", (PyCFunction)isgui, METH_NOARGS, |
|
546 "Is a CoreGraphics session available?" |
|
547 }, |
|
548 #endif |
527 {NULL, NULL} |
549 {NULL, NULL} |
528 }; |
550 }; |
529 |
551 |
530 #ifdef IS_PY3K |
552 #ifdef IS_PY3K |
531 static struct PyModuleDef osutil_module = { |
553 static struct PyModuleDef osutil_module = { |