1957 |
1964 |
1958 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock |
1965 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock |
1959 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
1966 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
1960 This is typically used to present help-files, html documents, pdf documents etc. |
1967 This is typically used to present help-files, html documents, pdf documents etc. |
1961 operationSymbol is one of: |
1968 operationSymbol is one of: |
1962 open |
1969 open |
1963 edit |
1970 edit |
1964 explore |
1971 explore |
1965 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'; |
1972 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'; |
1966 if nil is passed in, the file's suffix is used to guess it. |
1973 if nil is passed in, the file's suffix is used to guess it. |
1967 " |
1974 " |
1968 |
1975 |
1969 | cmd | |
1976 | cmd | |
1970 |
1977 |
1971 cmd := self openApplicationHelperCommand. |
1978 cmd := self openApplicationHelperCommand. |
1972 cmd notNil ifTrue:[ |
1979 cmd notNil ifTrue:[ |
1973 (cmd includesSubString:'%1') ifTrue:[ |
1980 (cmd includesSubString:'%1') ifTrue:[ |
1974 cmd := cmd bindWith:aFilenameOrString asString. |
1981 cmd := cmd bindWith:aFilenameOrString asString. |
1975 ] ifFalse:[ |
1982 ] ifFalse:[ |
1976 cmd := cmd, ' "', aFilenameOrString asString, '"'. |
1983 cmd := cmd, ' "', aFilenameOrString asString, '"'. |
1977 ]. |
1984 ]. |
1978 (self |
1985 (self |
1979 startProcess:cmd |
1986 startProcess:cmd |
1980 inputFrom:nil outputTo:nil |
1987 inputFrom:nil outputTo:nil |
1981 errorTo:nil auxFrom:nil |
1988 errorTo:nil auxFrom:nil |
1982 environment: self getEnvironment inDirectory:nil) notNil ifTrue:[ ^ self ] |
1989 environment: self getEnvironment inDirectory:nil) notNil ifTrue:[ ^ self ] |
1983 ]. |
1990 ]. |
1984 ^ super openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock |
1991 ^ super openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock |
1985 |
1992 |
1986 |
1993 |
1987 " |
1994 " |
2000 |
2007 |
2001 | xdgCurrentDesktop usersPref | |
2008 | xdgCurrentDesktop usersPref | |
2002 |
2009 |
2003 ((usersPref := UserPreferences current osFileExplorerCommand) notEmptyOrNil |
2010 ((usersPref := UserPreferences current osFileExplorerCommand) notEmptyOrNil |
2004 and:[ self canExecuteCommand:(usersPref subStrings first) ]) ifTrue:[ |
2011 and:[ self canExecuteCommand:(usersPref subStrings first) ]) ifTrue:[ |
2005 ^ usersPref |
2012 ^ usersPref |
2006 ]. |
2013 ]. |
2007 |
2014 |
2008 xdgCurrentDesktop := self getEnvironment: 'XDG_CURRENT_DESKTOP'. |
2015 xdgCurrentDesktop := self getEnvironment: 'XDG_CURRENT_DESKTOP'. |
2009 ((xdgCurrentDesktop = 'GNOME') and:[self canExecuteCommand: 'gnome-open']) ifTrue:[ |
2016 ((xdgCurrentDesktop = 'GNOME') and:[self canExecuteCommand: 'gnome-open']) ifTrue:[ |
2010 ^ 'gnome-open' |
2017 ^ 'gnome-open' |
2011 ]. |
2018 ]. |
2012 "/ Guess... |
2019 "/ Guess... |
2013 ((xdgCurrentDesktop = 'KDE') and:[self canExecuteCommand: 'kde-open']) ifTrue:[ |
2020 ((xdgCurrentDesktop = 'KDE') and:[self canExecuteCommand: 'kde-open']) ifTrue:[ |
2014 ^ 'kde-open' |
2021 ^ 'kde-open' |
2015 ]. |
2022 ]. |
2016 (self canExecuteCommand: 'xdg-open') ifTrue:[ |
2023 (self canExecuteCommand: 'xdg-open') ifTrue:[ |
2017 ^ 'xdg-open' |
2024 ^ 'xdg-open' |
2018 ]. |
2025 ]. |
2019 (self canExecuteCommand: 'nautilus') ifTrue:[ |
2026 (self canExecuteCommand: 'nautilus') ifTrue:[ |
2020 ^ 'nautilus' |
2027 ^ 'nautilus' |
2021 ]. |
2028 ]. |
2022 ^ nil |
2029 ^ nil |
2023 |
2030 |
2024 " |
2031 " |
2025 self openApplicationHelperCommand |
2032 self openApplicationHelperCommand |
4343 |
4350 |
4344 |encodedPathName| |
4351 |encodedPathName| |
4345 |
4352 |
4346 encodedPathName := self encodePath:aPathName. |
4353 encodedPathName := self encodePath:aPathName. |
4347 %{ |
4354 %{ |
4348 struct stat buf; |
4355 struct STATBUF buf; |
4349 int ret; |
4356 int ret; |
4350 |
4357 |
4351 if (__isStringLike(encodedPathName)) { |
4358 if (__isStringLike(encodedPathName)) { |
4352 # ifdef TRACE_STAT_CALLS |
4359 #ifdef TRACE_STAT_CALLS |
4353 printf("stat on '%s' for accessMode\n", __stringVal(encodedPathName)); |
4360 printf("stat on '%s' for accessMode\n", __stringVal(encodedPathName)); |
4354 # endif |
4361 #endif |
4355 __BEGIN_INTERRUPTABLE__ |
4362 __BEGIN_INTERRUPTABLE__ |
4356 do { |
4363 do { |
4357 ret = stat((char *) __stringVal(encodedPathName), &buf); |
4364 ret = STAT((char *) __stringVal(encodedPathName), &buf); |
4358 } while ((ret < 0) && (errno == EINTR)); |
4365 } while ((ret < 0) && (errno == EINTR)); |
4359 __END_INTERRUPTABLE__ |
4366 __END_INTERRUPTABLE__ |
4360 |
4367 |
4361 if (ret < 0) { |
4368 if (ret < 0) { |
4362 @global(LastErrorNumber) = __mkSmallInteger(errno); |
4369 @global(LastErrorNumber) = __mkSmallInteger(errno); |
4982 # ifdef TRACE_STAT_CALLS |
4989 # ifdef TRACE_STAT_CALLS |
4983 printf("stat on '%s' for info\n", __stringVal(aPathName)); |
4990 printf("stat on '%s' for info\n", __stringVal(aPathName)); |
4984 # endif |
4991 # endif |
4985 __BEGIN_INTERRUPTABLE__ |
4992 __BEGIN_INTERRUPTABLE__ |
4986 do { |
4993 do { |
4987 ret = stat((char *) __stringVal(encodedPathName), &buf); |
4994 ret = STAT((char *) __stringVal(encodedPathName), &buf); |
4988 } while ((ret < 0) && (errno == EINTR)); |
4995 } while ((ret < 0) && (errno == EINTR)); |
4989 __END_INTERRUPTABLE__ |
4996 __END_INTERRUPTABLE__ |
4990 |
4997 |
4991 if (ret < 0) { |
4998 if (ret < 0) { |
4992 error = __mkSmallInteger(errno); |
4999 error = __mkSmallInteger(errno); |
5116 } |
5123 } |
5117 #else |
5124 #else |
5118 int ret; |
5125 int ret; |
5119 |
5126 |
5120 if (__isStringLike(encodedPathName)) { |
5127 if (__isStringLike(encodedPathName)) { |
5121 struct stat buf; |
5128 struct STATBUF buf; |
5122 |
5129 |
5123 # ifdef TRACE_STAT_CALLS |
5130 # ifdef TRACE_STAT_CALLS |
5124 printf("stat on '%s' for isDirectory\n", __stringVal(encodedPathName)); |
5131 printf("stat on '%s' for isDirectory\n", __stringVal(encodedPathName)); |
5125 # endif |
5132 # endif |
5126 __BEGIN_INTERRUPTABLE__ |
5133 __BEGIN_INTERRUPTABLE__ |
5127 do { |
5134 do { |
5128 ret = stat((char *) __stringVal(encodedPathName), &buf); |
5135 ret = STAT((char *) __stringVal(encodedPathName), &buf); |
5129 } while ((ret < 0) && (errno == EINTR)); |
5136 } while ((ret < 0) && (errno == EINTR)); |
5130 __END_INTERRUPTABLE__ |
5137 __END_INTERRUPTABLE__ |
5131 if (ret < 0) { |
5138 if (ret < 0) { |
5132 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5139 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5133 RETURN ( false ); |
5140 RETURN ( false ); |
5241 return __c__._RETURN_true(); |
5248 return __c__._RETURN_true(); |
5242 } |
5249 } |
5243 return __c__._RETURN_false(); |
5250 return __c__._RETURN_false(); |
5244 } |
5251 } |
5245 #else |
5252 #else |
5246 struct stat buf; |
|
5247 int ret; |
|
5248 |
|
5249 if (__isStringLike(encodedPathName)) { |
5253 if (__isStringLike(encodedPathName)) { |
|
5254 struct STATBUF buf; |
|
5255 int ret; |
|
5256 |
5250 # ifdef TRACE_STAT_CALLS |
5257 # ifdef TRACE_STAT_CALLS |
5251 printf("stat on '%s' for isValidPath\n", __stringVal(encodedPathName)); |
5258 printf("stat on '%s' for isValidPath\n", __stringVal(encodedPathName)); |
5252 # endif |
5259 # endif |
5253 __BEGIN_INTERRUPTABLE__ |
5260 __BEGIN_INTERRUPTABLE__ |
5254 do { |
5261 do { |
5255 ret = stat((char *) __stringVal(encodedPathName), &buf); |
5262 ret = STAT((char *) __stringVal(encodedPathName), &buf); |
5256 } while ((ret < 0) && (errno == EINTR)); |
5263 } while ((ret < 0) && (errno == EINTR)); |
5257 __END_INTERRUPTABLE__ |
5264 __END_INTERRUPTABLE__ |
5258 if (ret < 0) { |
5265 if (ret < 0) { |
5259 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5266 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5260 RETURN (false); |
5267 RETURN (false); |
5650 |
5657 |
5651 |encodedPathName| |
5658 |encodedPathName| |
5652 |
5659 |
5653 encodedPathName := self encodePath:aPathName. |
5660 encodedPathName := self encodePath:aPathName. |
5654 %{ |
5661 %{ |
5655 struct stat buf; |
|
5656 int ret; |
|
5657 unsigned INT ino; |
|
5658 OBJ retVal; |
|
5659 |
|
5660 if (__isStringLike(encodedPathName)) { |
5662 if (__isStringLike(encodedPathName)) { |
|
5663 struct STATBUF buf; |
|
5664 unsigned INT ino; |
|
5665 OBJ retVal; |
|
5666 int ret; |
|
5667 |
5661 # ifdef TRACE_STAT_CALLS |
5668 # ifdef TRACE_STAT_CALLS |
5662 printf("stat on '%s' for id\n", __stringVal(encodedPathName)); |
5669 printf("stat on '%s' for id\n", __stringVal(encodedPathName)); |
5663 # endif |
5670 # endif |
5664 __BEGIN_INTERRUPTABLE__ |
5671 __BEGIN_INTERRUPTABLE__ |
5665 do { |
5672 do { |
5666 ret = stat((char *) __stringVal(encodedPathName), &buf); |
5673 ret = STAT((char *) __stringVal(encodedPathName), &buf); |
5667 } while (ret < 0 && errno == EINTR); |
5674 } while (ret < 0 && errno == EINTR); |
5668 __END_INTERRUPTABLE__ |
5675 __END_INTERRUPTABLE__ |
5669 if (ret >= 0) { |
5676 if (ret >= 0) { |
5670 ino = buf.st_ino; |
5677 ino = buf.st_ino; |
5671 retVal = __MKUINT(ino); |
5678 retVal = __MKUINT(ino); |
5749 |osSeconds i encodedPathName| |
5756 |osSeconds i encodedPathName| |
5750 |
5757 |
5751 encodedPathName := self encodePath:aPathName. |
5758 encodedPathName := self encodePath:aPathName. |
5752 |
5759 |
5753 %{ |
5760 %{ |
5754 struct stat buf; |
|
5755 time_t mtime; |
|
5756 int ret; |
|
5757 |
|
5758 if (__isStringLike(encodedPathName)) { |
5761 if (__isStringLike(encodedPathName)) { |
|
5762 struct STATBUF buf; |
|
5763 time_t mtime; |
|
5764 int ret; |
|
5765 |
5759 # ifdef TRACE_STAT_CALLS |
5766 # ifdef TRACE_STAT_CALLS |
5760 printf("stat on '%s' for timeOfLastAccess\n", __stringVal(encodedPathName)); |
5767 printf("stat on '%s' for timeOfLastAccess\n", __stringVal(encodedPathName)); |
5761 # endif |
5768 # endif |
5762 __BEGIN_INTERRUPTABLE__ |
5769 __BEGIN_INTERRUPTABLE__ |
5763 do { |
5770 do { |
5764 ret = stat((char *) __stringVal(encodedPathName), &buf); |
5771 ret = STAT((char *) __stringVal(encodedPathName), &buf); |
5765 } while (ret < 0 && errno == EINTR); |
5772 } while (ret < 0 && errno == EINTR); |
5766 __END_INTERRUPTABLE__ |
5773 __END_INTERRUPTABLE__ |
5767 if (ret < 0) { |
5774 if (ret < 0) { |
5768 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5775 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5769 RETURN (nil); |
5776 RETURN (nil); |
5792 |
5799 |
5793 |osSeconds i encodedPathName| |
5800 |osSeconds i encodedPathName| |
5794 |
5801 |
5795 encodedPathName := self encodePath:aPathName. |
5802 encodedPathName := self encodePath:aPathName. |
5796 %{ |
5803 %{ |
5797 struct stat buf; |
|
5798 int ret; |
|
5799 time_t mtime; |
|
5800 |
|
5801 if (__isStringLike(encodedPathName)) { |
5804 if (__isStringLike(encodedPathName)) { |
|
5805 struct STATBUF buf; |
|
5806 int ret; |
|
5807 time_t mtime; |
|
5808 |
5802 # ifdef TRACE_STAT_CALLS |
5809 # ifdef TRACE_STAT_CALLS |
5803 printf("stat on '%s' for timeOfLastChange\n", __stringVal(encodedPathName)); |
5810 printf("stat on '%s' for timeOfLastChange\n", __stringVal(encodedPathName)); |
5804 # endif |
5811 # endif |
5805 __BEGIN_INTERRUPTABLE__ |
5812 __BEGIN_INTERRUPTABLE__ |
5806 do { |
5813 do { |
5807 ret = stat((char *) __stringVal(encodedPathName), &buf); |
5814 ret = STAT((char *) __stringVal(encodedPathName), &buf); |
5808 } while (ret < 0 && errno == EINTR); |
5815 } while (ret < 0 && errno == EINTR); |
5809 __END_INTERRUPTABLE__ |
5816 __END_INTERRUPTABLE__ |
5810 if (ret < 0) { |
5817 if (ret < 0) { |
5811 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5818 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5812 RETURN ( nil ); |
5819 RETURN ( nil ); |
5839 (self infoOf:aPathName) type |
5846 (self infoOf:aPathName) type |
5840 but for huge directory searches the code below is faster |
5847 but for huge directory searches the code below is faster |
5841 " |
5848 " |
5842 |
5849 |
5843 %{ |
5850 %{ |
5844 struct stat buf; |
|
5845 int ret; |
|
5846 |
|
5847 if (__isStringLike(encodedPathName)) { |
5851 if (__isStringLike(encodedPathName)) { |
|
5852 struct STATBUF buf; |
|
5853 int ret; |
|
5854 |
5848 # ifdef TRACE_STAT_CALLS |
5855 # ifdef TRACE_STAT_CALLS |
5849 printf("stat on '%s' for type\n", __stringVal(encodedPathName)); |
5856 printf("stat on '%s' for type\n", __stringVal(encodedPathName)); |
5850 # endif |
5857 # endif |
5851 __BEGIN_INTERRUPTABLE__ |
5858 __BEGIN_INTERRUPTABLE__ |
5852 do { |
5859 do { |
5853 ret = stat((char *) __stringVal(encodedPathName), &buf); |
5860 ret = STAT((char *) __stringVal(encodedPathName), &buf); |
5854 } while (ret < 0 && errno == EINTR); |
5861 } while (ret < 0 && errno == EINTR); |
5855 __END_INTERRUPTABLE__ |
5862 __END_INTERRUPTABLE__ |
5856 if (ret < 0) { |
5863 if (ret < 0) { |
5857 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5864 @global(LastErrorNumber) = __mkSmallInteger(errno); |
5858 RETURN ( nil ); |
5865 RETURN ( nil ); |