* Carbon port: setting the creator code (patch)
@ 2005-06-24 9:05 David Reitter
2005-07-09 3:04 ` Steven Tamm
0 siblings, 1 reply; 9+ messages in thread
From: David Reitter @ 2005-06-24 9:05 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 640 bytes --]
I'm posting some code that introduces a function "mac-set-creator" in
the Mac (Carbon) port. The function sets the creator code (metadata
information) of a file to 'EMAx'. That enables LaunchServices to
start up Emacs whenever the file is double-clicked.
In the Aquamacs distribution, I use it as follows:
(defun mac-set-creator-code-for-file ()
(if (and aquamacs-set-creator-codes-after-writing-files
buffer-file-name
(fboundp 'mac-set-creator)
)
(mac-set-creator buffer-file-name)
)
)
(add-hook 'after-save-hook 'mac-set-creator-code-for-file)
This contains some free code from Apple.
[-- Attachment #2: mac-set-creator.patch --]
[-- Type: application/octet-stream, Size: 5339 bytes --]
Index: macfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macfns.c,v
retrieving revision 1.61
diff -c -r1.61 macfns.c
*** macfns.c 23 Jun 2005 16:12:25 -0000 1.61
--- macfns.c 24 Jun 2005 08:51:24 -0000
***************
*** 4406,4411 ****
--- 4406,4570 ----
{
}
#endif
+
+
+ #ifdef MAC_OSX
+
+
+ /* The code for FSBumpDate and FSChangeCreator is taken from
+ MoreFilesX.c (Apple Sample Code), authored by Jim Luther / Apple
+ and released for free use. The code has been modified.
+
+ To do: test on MacOS.
+ */
+
+ OSErr
+ FSBumpDate(
+ const FSRef *ref)
+ {
+ OSStatus result;
+ FSCatalogInfo catalogInfo;
+ UTCDateTime oldDateTime;
+ #ifdef MAC_OSX
+ FSRef parentRef;
+ Boolean notifyParent;
+ #endif
+
+ #ifdef MAC_OSX
+ /* Get the node flags, the content modification date and time, and the parent ref */
+ result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags + kFSCatInfoContentMod, &catalogInfo, NULL, NULL, &parentRef);
+ require_noerr(result, FSGetCatalogInfo);
+
+ /* Notify the parent if this is a file */
+ notifyParent = (0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask));
+ #else
+ /* Get the content modification date and time */
+ result = FSGetCatalogInfo(ref, kFSCatInfoContentMod, &catalogInfo, NULL, NULL, NULL);
+ require_noerr(result, FSGetCatalogInfo);
+ #endif
+
+ oldDateTime = catalogInfo.contentModDate;
+
+ /* Get the current date and time */
+ result = GetUTCDateTime(&catalogInfo.contentModDate, kUTCDefaultOptions);
+ require_noerr(result, GetUTCDateTime);
+
+ /* if the old date and time is the the same as the current, bump the seconds by one */
+ if ( (catalogInfo.contentModDate.fraction == oldDateTime.fraction) &&
+ (catalogInfo.contentModDate.lowSeconds == oldDateTime.lowSeconds) &&
+ (catalogInfo.contentModDate.highSeconds == oldDateTime.highSeconds) )
+ {
+ ++catalogInfo.contentModDate.lowSeconds;
+ if ( 0 == catalogInfo.contentModDate.lowSeconds )
+ {
+ ++catalogInfo.contentModDate.highSeconds;
+ }
+ }
+
+ /* Bump the content modification date and time */
+ result = FSSetCatalogInfo(ref, kFSCatInfoContentMod, &catalogInfo);
+ require_noerr(result, FSSetCatalogInfo);
+
+ #if MAC_OSX
+ /*
+ * The problem with FNNotify is that it is not available under Mac OS 9
+ * and there's no way to test for that except for looking for the symbol
+ * or something. So, I'll just conditionalize this for those who care
+ * to send a notification.
+ */
+
+ /* Send a notification for the parent of the file, or for the directory */
+ result = FNNotify(notifyParent ? &parentRef : ref, kFNDirectoryModifiedMessage, kNilOptions);
+ require_noerr(result, FNNotify);
+ #endif
+
+ /* ignore errors from FSSetCatalogInfo (volume might be write protected) and FNNotify */
+ FNNotify:
+ FSSetCatalogInfo:
+
+ return ( noErr );
+
+ /**********************/
+
+ GetUTCDateTime:
+ FSGetCatalogInfo:
+
+ return ( result );
+ }
+
+
+ OSErr
+ FSChangeCreator(
+ const FSRef *ref,
+ OSType fileCreator)
+ {
+ OSErr result;
+ FSCatalogInfo catalogInfo;
+ FSRef parentRef;
+
+ /* get nodeFlags, finder info, and parent FSRef */
+ result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags +
+ kFSCatInfoFinderInfo, &catalogInfo ,
+ NULL, NULL, &parentRef);
+ require_noerr(result, FSGetCatalogInfo);
+
+ /* make sure FSRef was to a file */
+ require_action(0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask),
+ FSRefNotFile, result = notAFileErr);
+
+
+ /* If creator not 0x00000000, change creator */
+ if ( fileCreator != (OSType)0x00000000 )
+ {
+ ((FileInfo *)&catalogInfo.finderInfo)->fileCreator = fileCreator;
+ }
+
+ /* now, save the new information back to disk */
+ result = FSSetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo);
+ require_noerr(result, FSSetCatalogInfo);
+
+ /* and attempt to bump the parent directory's mod date to wake up */
+ /* the Finder to the change we just made (ignore errors from this) */
+ verify_noerr(FSBumpDate(&parentRef));
+
+ FSSetCatalogInfo:
+ FSRefNotFile:
+ FSGetCatalogInfo:
+
+ return ( result );
+ }
+
+
+ DEFUN ("mac-set-creator", Fmac_set_creator, Smac_set_creator, 1, 1, 0,
+ doc: /* Set creator code of file PATH to 'EMAx'.
+ PATH must be a fully qualified file name.
+ Return non-nil if successful.
+ */)
+ (path)
+ Lisp_Object path;
+ {
+ CHECK_STRING (path);
+
+ OSErr status;
+ FSRef defLoc;
+ status = FSPathMakeRef(SDATA(ENCODE_FILE(path)), &defLoc, NULL);
+
+ if (status == noErr)
+ {
+ status = FSChangeCreator(&defLoc, (OSType) 'EMAx');
+
+ if (status == noErr)
+ return Qt;
+ }
+ return Qnil;
+ }
+
+
+
+ #endif
+
+
+
\f
/***********************************************************************
Initialization
***************
*** 4617,4622 ****
--- 4776,4784 ----
#if TARGET_API_MAC_CARBON
defsubr (&Sx_file_dialog);
#endif
+ #if MAC_OSX
+ defsubr (&Smac_set_creator);
+ #endif
}
/* arch-tag: d7591289-f374-4377-b245-12f5dbbb8edc
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Carbon port: setting the creator code (patch)
2005-06-24 9:05 Carbon port: setting the creator code (patch) David Reitter
@ 2005-07-09 3:04 ` Steven Tamm
2005-07-09 8:11 ` Sébastien Kirche
2005-07-09 13:06 ` David Reitter
0 siblings, 2 replies; 9+ messages in thread
From: Steven Tamm @ 2005-07-09 3:04 UTC (permalink / raw)
Cc: emacs-devel '
Sorry for the delay in reply, but it seems to me that using SetFile
would be easier, and more flexible.
(defun mac-set-creator-code-for-file ()
(call-process shell-file-name nil nil t shell-command-switch
(concat "/Developer/Tools/SetFile -c EMAx " buffer-file-name))
)
(add-hook 'after-save-hook 'mac-set-creator-code-for-file)
-Steven
On Jun 24, 2005, at 2:05 AM, David Reitter wrote:
> I'm posting some code that introduces a function "mac-set-creator"
> in the Mac (Carbon) port. The function sets the creator code
> (metadata information) of a file to 'EMAx'. That enables
> LaunchServices to start up Emacs whenever the file is double-clicked.
>
> In the Aquamacs distribution, I use it as follows:
>
> (defun mac-set-creator-code-for-file ()
> (if (and aquamacs-set-creator-codes-after-writing-files
> buffer-file-name
> (fboundp 'mac-set-creator)
> )
> (mac-set-creator buffer-file-name)
> )
> )
>
> (add-hook 'after-save-hook 'mac-set-creator-code-for-file)
>
> This contains some free code from Apple.
>
>
> <mac-set-creator.patch>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Carbon port: setting the creator code (patch)
2005-07-09 3:04 ` Steven Tamm
@ 2005-07-09 8:11 ` Sébastien Kirche
2005-07-09 13:06 ` David Reitter
1 sibling, 0 replies; 9+ messages in thread
From: Sébastien Kirche @ 2005-07-09 8:11 UTC (permalink / raw)
At 05:07 on jui 9 2005, Steven Tamm said :
> Sorry for the delay in reply, but it seems to me that using SetFile
> would be easier, and more flexible.
The problem is that the installation of the Developer Tools is
optional, so every Mac Emacs user will not have SetFile installed...
--
Sébastien Kirche
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Carbon port: setting the creator code (patch)
2005-07-09 3:04 ` Steven Tamm
2005-07-09 8:11 ` Sébastien Kirche
@ 2005-07-09 13:06 ` David Reitter
2005-07-09 16:08 ` Steven Tamm
1 sibling, 1 reply; 9+ messages in thread
From: David Reitter @ 2005-07-09 13:06 UTC (permalink / raw)
On 9 Jul 2005, at 04:04, Steven Tamm wrote:
> Sorry for the delay in reply, but it seems to me that using SetFile
> would be easier, and more flexible.
>
> (defun mac-set-creator-code-for-file ()
> (call-process shell-file-name nil nil t shell-command-switch
> (concat "/Developer/Tools/SetFile -c EMAx " buffer-file-name))
> )
> (add-hook 'after-save-hook 'mac-set-creator-code-for-file)
SetFile is only available if the Developer Tools are installed. That
is not necessarily the case, and the other code doesn't introduce
that dependency.
The correct way to set file metadata is to go through Carbon, in this
case. That's what the API is for...
-Dave
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Carbon port: setting the creator code (patch)
2005-07-09 13:06 ` David Reitter
@ 2005-07-09 16:08 ` Steven Tamm
2005-07-10 0:56 ` YAMAMOTO Mitsuharu
2005-07-10 11:16 ` David Reitter
0 siblings, 2 replies; 9+ messages in thread
From: Steven Tamm @ 2005-07-09 16:08 UTC (permalink / raw)
Cc: emacs-devel '
Fine. You can do the same thing with osascript (although it's much
more annoying).
The problem I have with it is that it will only set it to "EMAx", it
can't set the file type, it will modify the creator code of already
existing files, it doesn't test for UFS drives, etc.
http://developer.apple.com/technotes/tn/tn2017.html
Furthermore, Creator codes are being deprecated and replaced with
file extension based mapping or Universal Type Identifiers.
http://developer.apple.com/documentation/Carbon/Conceptual/
understanding_utis/
I have modified by system so that Emacs is the launch services
default for text files with RCDefaultApp.
http://www.versiontracker.com/dyn/moreinfo/macosx/22977
That doesn't mean we shouldn't add the feature to "set a creator
code", but it should take in the code as a parameter (a four
character string or a 32-bit number).
(mac-set-creator-type "EMAx")
(mac-set-file-type "TEXT")
-Steven
On Jul 9, 2005, at 6:06 AM, David Reitter wrote:
> On 9 Jul 2005, at 04:04, Steven Tamm wrote:
>
>
>> Sorry for the delay in reply, but it seems to me that using
>> SetFile would be easier, and more flexible.
>>
>> (defun mac-set-creator-code-for-file ()
>> (call-process shell-file-name nil nil t shell-command-switch
>> (concat "/Developer/Tools/SetFile -c EMAx " buffer-file-name))
>> )
>> (add-hook 'after-save-hook 'mac-set-creator-code-for-file)
>>
>
>
> SetFile is only available if the Developer Tools are installed.
> That is not necessarily the case, and the other code doesn't
> introduce that dependency.
> The correct way to set file metadata is to go through Carbon, in
> this case. That's what the API is for...
>
> -Dave
>
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Carbon port: setting the creator code (patch)
2005-07-09 16:08 ` Steven Tamm
@ 2005-07-10 0:56 ` YAMAMOTO Mitsuharu
2005-07-10 11:55 ` David Reitter
2005-07-10 11:16 ` David Reitter
1 sibling, 1 reply; 9+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-07-10 0:56 UTC (permalink / raw)
Cc: Steven Tamm, emacs-devel
>>>>> On Sat, 9 Jul 2005 09:08:16 -0700, Steven Tamm <steventamm@mac.com> said:
> That doesn't mean we shouldn't add the feature to "set a creator
> code", but it should take in the code as a parameter (a four
> character string or a 32-bit number).
> (mac-set-creator-type "EMAx")
> (mac-set-file-type "TEXT")
Apparently the argument for a file name is missing. :-)
I think these functions should follow the convention of existing
operations on files. For example, with respect to the default
directory, error handling, and argument names. Maybe the function
name should be "mac-set-file-creator". We can additionally think of
"mac-file-creator" and "mac-file-type", or "mac-file-attributes" for
reading these kinds of information.
And more importantly, please care about BLOCK_INPUT when adding new C
functions. It required much effort to fill missing BLOCK_INPUTs that
had been a cause of unstability in the Carbon port.
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Carbon port: setting the creator code (patch)
2005-07-09 16:08 ` Steven Tamm
2005-07-10 0:56 ` YAMAMOTO Mitsuharu
@ 2005-07-10 11:16 ` David Reitter
2005-07-10 13:30 ` Benjamin Riefenstahl
1 sibling, 1 reply; 9+ messages in thread
From: David Reitter @ 2005-07-10 11:16 UTC (permalink / raw)
Cc: emacs-devel '
On 9 Jul 2005, at 17:08, Steven Tamm wrote:
> Fine. You can do the same thing with osascript (although it's much
> more annoying).
I did that for a while, until I had a bug report from a user saying
that it started Finder every time he saved a file. The AppleScript
had to go through the Finder to set the creator code. Turns out that
the user was running a replacement for Finder. Lesson learned:
AppleScript is only a user-level API. :-(
> The problem I have with it is that it will only set it to "EMAx",
> it can't set the file type, it will modify the creator code of
> already existing files, it doesn't test for UFS drives, etc.
> http://developer.apple.com/technotes/tn/tn2017.html
It is meant to modify the creator code of an existing file.
I don't know if we need to check for UFS drives (works fine for me on
SMB mounts; the OS takes care of creating metadata files which is not
nice, but none of our business on application level). I don't know
how to check for that - maybe you can add that.
> Furthermore, Creator codes are being deprecated and replaced with
> file extension based mapping or Universal Type Identifiers.
> http://developer.apple.com/documentation/Carbon/Conceptual/
> understanding_utis/
Yes they are and that is known, but users wanted it and I hear it
plays a role in Spotlight. (I don't know anything about that in detail.)
> That doesn't mean we shouldn't add the feature to "set a creator
> code", but it should take in the code as a parameter (a four
> character string or a 32-bit number).
> (mac-set-creator-type "EMAx")
> (mac-set-file-type "TEXT")
Yes, done. See next message.
- D
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Carbon port: setting the creator code (patch)
2005-07-10 0:56 ` YAMAMOTO Mitsuharu
@ 2005-07-10 11:55 ` David Reitter
0 siblings, 0 replies; 9+ messages in thread
From: David Reitter @ 2005-07-10 11:55 UTC (permalink / raw)
Cc: Steven Tamm, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 858 bytes --]
On 10 Jul 2005, at 01:56, YAMAMOTO Mitsuharu wrote:
> I think these functions should follow the convention of existing
> operations on files. For example, with respect to the default
> directory, error handling, and argument names. Maybe the function
> name should be "mac-set-file-creator". We can additionally think of
> "mac-file-creator" and "mac-file-type", or "mac-file-attributes" for
> reading these kinds of information.
OK, what I have now is
(mac-set-file-creator filename &optional code)
(mac-set-file-type filename type)
They throw errors if code or type or filename are bad.
> And more importantly, please care about BLOCK_INPUT when adding new C
> functions. It required much effort to fill missing BLOCK_INPUTs that
> had been a cause of unstability in the Carbon port.
OK, done. Hope I got that right.
The new patch is enclosed.
[-- Attachment #2: mac-set-creator.patch --]
[-- Type: application/octet-stream, Size: 7529 bytes --]
Index: macfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macfns.c,v
retrieving revision 1.63
diff -c -r1.63 macfns.c
*** macfns.c 4 Jul 2005 16:06:33 -0000 1.63
--- macfns.c 10 Jul 2005 11:52:18 -0000
***************
*** 4406,4411 ****
--- 4406,4656 ----
{
}
#endif
+
+
+ #ifdef MAC_OSX
+
+
+ /* The code for FSBumpDate and FSChangeCreatorType is taken from
+ MoreFilesX.c (Apple Sample Code), authored by Jim Luther / Apple
+ and released for free use. The code has been modified.
+
+ To do: test on MacOS.
+ */
+
+ OSErr
+ FSBumpDate(
+ const FSRef *ref)
+ {
+ OSStatus result;
+ FSCatalogInfo catalogInfo;
+ UTCDateTime oldDateTime;
+ #ifdef MAC_OSX
+ FSRef parentRef;
+ Boolean notifyParent;
+ #endif
+
+ #ifdef MAC_OSX
+ /* Get the node flags, the content modification date and time, and the parent ref */
+ result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags + kFSCatInfoContentMod, &catalogInfo, NULL, NULL, &parentRef);
+ require_noerr(result, FSGetCatalogInfo);
+
+ /* Notify the parent if this is a file */
+ notifyParent = (0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask));
+ #else
+ /* Get the content modification date and time */
+ result = FSGetCatalogInfo(ref, kFSCatInfoContentMod, &catalogInfo, NULL, NULL, NULL);
+ require_noerr(result, FSGetCatalogInfo);
+ #endif
+
+ oldDateTime = catalogInfo.contentModDate;
+
+ /* Get the current date and time */
+ result = GetUTCDateTime(&catalogInfo.contentModDate, kUTCDefaultOptions);
+ require_noerr(result, GetUTCDateTime);
+
+ /* if the old date and time is the the same as the current, bump the seconds by one */
+ if ( (catalogInfo.contentModDate.fraction == oldDateTime.fraction) &&
+ (catalogInfo.contentModDate.lowSeconds == oldDateTime.lowSeconds) &&
+ (catalogInfo.contentModDate.highSeconds == oldDateTime.highSeconds) )
+ {
+ ++catalogInfo.contentModDate.lowSeconds;
+ if ( 0 == catalogInfo.contentModDate.lowSeconds )
+ {
+ ++catalogInfo.contentModDate.highSeconds;
+ }
+ }
+
+ /* Bump the content modification date and time */
+ result = FSSetCatalogInfo(ref, kFSCatInfoContentMod, &catalogInfo);
+ require_noerr(result, FSSetCatalogInfo);
+
+ #if MAC_OSX
+ /*
+ * The problem with FNNotify is that it is not available under Mac OS 9
+ * and there's no way to test for that except for looking for the symbol
+ * or something. So, I'll just conditionalize this for those who care
+ * to send a notification.
+ */
+
+ /* Send a notification for the parent of the file, or for the directory */
+ result = FNNotify(notifyParent ? &parentRef : ref, kFNDirectoryModifiedMessage, kNilOptions);
+ require_noerr(result, FNNotify);
+ #endif
+
+ /* ignore errors from FSSetCatalogInfo (volume might be write protected) and FNNotify */
+ FNNotify:
+ FSSetCatalogInfo:
+
+ return ( noErr );
+
+ /**********************/
+
+ GetUTCDateTime:
+ FSGetCatalogInfo:
+
+ return ( result );
+ }
+
+
+ OSErr
+ FSChangeCreatorType(
+ const FSRef *ref,
+ OSType fileCreator,
+ OSType fileType)
+ {
+ OSErr result;
+ FSCatalogInfo catalogInfo;
+ FSRef parentRef;
+
+ /* get nodeFlags, finder info, and parent FSRef */
+ result = FSGetCatalogInfo(ref, kFSCatInfoNodeFlags +
+ kFSCatInfoFinderInfo, &catalogInfo ,
+ NULL, NULL, &parentRef);
+ require_noerr(result, FSGetCatalogInfo);
+
+ /* make sure FSRef was to a file */
+ require_action(0 == (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask),
+ FSRefNotFile, result = notAFileErr);
+
+
+ /* If creator not 0x00000000, change creator */
+ if (fileCreator && fileCreator != (OSType)0x00000000 )
+ {
+ ((FileInfo *)&catalogInfo.finderInfo)->fileCreator = fileCreator;
+ }
+ /* If type not 0x00000000, change type */
+ if (fileType && fileType != (OSType)0x00000000 )
+ {
+ ((FileInfo *)&catalogInfo.finderInfo)->fileType = fileType;
+ }
+
+ /* now, save the new information back to disk */
+ result = FSSetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo);
+ require_noerr(result, FSSetCatalogInfo);
+
+ /* and attempt to bump the parent directory's mod date to wake up */
+ /* the Finder to the change we just made (ignore errors from this) */
+ verify_noerr(FSBumpDate(&parentRef));
+
+ FSSetCatalogInfo:
+ FSRefNotFile:
+ FSGetCatalogInfo:
+
+ return ( result );
+ }
+
+
+ DEFUN ("mac-set-file-creator", Fmac_set_file_creator, Smac_set_file_creator, 1, 2, 0,
+ doc: /* Set creator code of file FILENAME to CODE.
+ If non-nil, CODE must be a 4-character string. Otherwise,
+ 'EMAx' is assumed. Return non-nil if successful.
+ */)
+ (filename, code)
+ Lisp_Object filename;
+ Lisp_Object code;
+ {
+
+
+
+
+ CHECK_STRING (filename);
+ OSErr status;
+ FSRef defLoc;
+ OSType cCode;
+
+ if (NILP(code))
+ {
+ cCode = 'EMAx';
+ }
+ else
+ {
+ /* check type string */
+ CHECK_STRING(code);
+ if (strlen(SDATA(code)) != 4)
+ {
+ error ("Wrong argument: need string of length 4 for CODE");
+ }
+ cCode = (OSType) *((int *) SDATA(code));
+ }
+ BLOCK_INPUT;
+ filename = Fexpand_file_name (filename, Qnil);
+ status = FSPathMakeRef(SDATA(ENCODE_FILE(filename)), &defLoc, NULL);
+
+
+ if (status == noErr)
+ {
+ status = FSChangeCreatorType(&defLoc, cCode, (OSType) 0);
+ UNBLOCK_INPUT;
+
+ if (status == noErr)
+ {
+ return Qt;
+ }
+ else
+ error ("Error while setting creator information.");
+ }
+ else
+ {
+ UNBLOCK_INPUT;
+ error ("Error while accessing file.");
+ }
+ }
+
+
+ DEFUN ("mac-set-file-type", Fmac_set_file_type, Smac_set_file_type, 2, 2, 0,
+ doc: /* Set type of file FILENAME to TYPE.
+ TYPE must be a 4-character string.
+ Return non-nil if successful.
+ */)
+ (filename,type)
+ Lisp_Object filename;
+ Lisp_Object type;
+ {
+ OSErr status;
+ FSRef defLoc;
+
+ CHECK_STRING (filename);
+
+ /* check type string */
+ CHECK_STRING(type);
+ if (strlen(SDATA(type)) != 4)
+ {
+ error ("Wrong argument: need string of length 4 for CODE");
+ }
+
+ BLOCK_INPUT;
+ filename = Fexpand_file_name (filename, Qnil);
+ status = FSPathMakeRef(SDATA(ENCODE_FILE(filename)), &defLoc, NULL);
+
+ if (status == noErr)
+ {
+ /* warning: the string-to-OSType conversion here might not be safe
+ when using Intel type endians... */
+
+ status = FSChangeCreatorType(&defLoc,
+ (OSType) 0,
+ (OSType) *((int *) SDATA(type)));
+ UNBLOCK_INPUT;
+ if (status == noErr)
+ {
+ return Qt;
+ }
+ else
+ error ("Error while setting creator information.");
+ }
+ else
+ {
+ UNBLOCK_INPUT;
+ error ("Error while accessing file.");
+ }
+ }
+
+
+ #endif
+
+
+
\f
/***********************************************************************
Initialization
***************
*** 4616,4621 ****
--- 4861,4870 ----
#if TARGET_API_MAC_CARBON
defsubr (&Sx_file_dialog);
+ #endif
+ #if MAC_OSX
+ defsubr (&Smac_set_file_creator);
+ defsubr (&Smac_set_file_type);
#endif
}
[-- Attachment #3: Type: text/plain, Size: 1 bytes --]
[-- Attachment #4: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Carbon port: setting the creator code (patch)
2005-07-10 11:16 ` David Reitter
@ 2005-07-10 13:30 ` Benjamin Riefenstahl
0 siblings, 0 replies; 9+ messages in thread
From: Benjamin Riefenstahl @ 2005-07-10 13:30 UTC (permalink / raw)
Cc: Steven Tamm, emacs-devel '
Hi David,
David Reitter writes:
> I don't know if we need to check for UFS drives (works fine for me
> on SMB mounts; [...]
UFS works the same as SMB.
> I don't know how to check for that - maybe you can add that.
You can use "Disk Utility" to create a disk image, repartition the
image to change the filesystem to UFS and test on that image.
benny
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-07-10 13:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-24 9:05 Carbon port: setting the creator code (patch) David Reitter
2005-07-09 3:04 ` Steven Tamm
2005-07-09 8:11 ` Sébastien Kirche
2005-07-09 13:06 ` David Reitter
2005-07-09 16:08 ` Steven Tamm
2005-07-10 0:56 ` YAMAMOTO Mitsuharu
2005-07-10 11:55 ` David Reitter
2005-07-10 11:16 ` David Reitter
2005-07-10 13:30 ` Benjamin Riefenstahl
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).