 |
|
 |
|
Next: creating a transparent os-x icon
|
| Author |
Message |
External

Since: Oct 22, 2003 Posts: 6
|
(Msg. 1) Posted: Thu Feb 26, 2004 12:07 pm
Post subject: problem creating a file (rather long) Archived from groups: comp>sys>mac>programmer>misc (more info?)
|
|
|
hello,
I write an application (carbon), both for OS9 and OS X. By the way, I'm
still looking for an IDE
able to produce the two executables on a single plateform. I'm currently
working alternatively with
ProjectBuilder and CodeWarrior to do that. But it is not my main problem
:-(((
My app have to propose three choices for locating the destination folder
for the new file:
the desktop (it works), the same location as the source (it works), and
a custom destination
stored in the prefs, after being located but the user: doesn't work.
I have tried this way:
In the prefs dialog, I call "NavCreateChooseFolderDialog" to allow the
user to select his
destination folder. First little problem: this dialog displays itself
with an "open" label for the
accept button, instead of the "choose" I want, and no "Open" button to
allow the user to navigate ???
I have select options by the following code:
osError = NavGetDefaultDialogCreationOptions (&dialogOptions);
dialogOptions.optionFlags = kNavDefaultNavDlogOptions; /*
defaults options*/
dialogOptions.optionFlags += kNavAllFilesInPopup; /* allows "all
documents"*/
dialogOptions.optionFlags -= kNavAllowStationery; /* no
"Stationery"*/
dialogOptions.optionFlags -= kNavAllowPreviews; /* no
"Previews"*/
dialogOptions.optionFlags -= kNavDontAddRecents; /* don't add
Recents;*/
dialogOptions.optionFlags -= kNavAllowMultipleFiles; /* unique
selection;*/
Then I call :
NavCreateChooseFolderDialog (&dialogOptions,
gChooseFolderEventFunctionUPP,
NULL,
NULL,
&gModalToApplicationNavDialogRef)
and, in the event function, I have:
switch (navUserAction)
{
case kNavUserActionChoose:
if ((osError = AEGetNthPtr
(&(navReplyStruc.selection),
1,
typeFSS,
&keyWord,
&typeCode,
&volatileFSSpec,
sizeof(FSSpec),
&actualSize)) ==
noErr) { ....
So, I hope to have the FSSpec of the directory where I should put my
file...
To be clean, I store only the path of this directory in my prefs. I have
this path
using a FSRef.
When I try to create my file, I first convert the path into a FSRef of
the directory:
osError = FSMakeFSSpec (0,
0,
currentPrefs.destPath,
&localeFSSpec);
Then, I use this FSSpec's vRefNum and parID, added to my fileName, to
create the
good FSSpec.
osError = FSMakeFSSpec (localeFSSpec.vRefNum,
localeFSSpec.parID,
theOutputFSSpecPtr->name,
theOutputFSSpecPtr);
The file is created, under OSX, in the application's package !!!!
I'm sure that I have follow the simpliest path, and ready to change my
options.
But I need help.
Thanks for any argumented suggestion. >> Stay informed about: problem creating a file (rather long) |
|
| Back to top |
|
 |  |
External

Since: May 10, 2004 Posts: 973
|
(Msg. 2) Posted: Thu Feb 26, 2004 12:07 pm
Post subject: Re: problem creating a file (rather long) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <403DA940.5630FC2D.DeleteThis@supelec.frNOSPAM>,
henri delebecque <henri.delebecque.DeleteThis@supelec.frNOSPAM> wrote:
> I write an application (carbon), both for OS9 and OS X. By the way, I'm still
> looking for an IDE able to produce the two executables on a single plateform.
> I'm currently working alternatively with ProjectBuilder and CodeWarrior to do
> that. But it is not my main problem
CodeWarrior works fine for both Mac OS 9 and Mac OS X.
> I have tried this way: In the prefs dialog, I call
> "NavCreateChooseFolderDialog" to allow the user to select his destination
> folder. First little problem: this dialog displays itself with an "open"
> label for the accept button, instead of the "choose" I want, and no "Open"
> button to allow the user to navigate ???
I believe this mislabeling is a known bug in Mac OS X 10.3 and will be fixed.
The "Open" button is not used for folder navigation at all.
> To be clean, I store only the path of this directory in my prefs. I have
> this path using a FSRef.
You should probably be saving an alias, not a path.
> When I try to create my file, I first convert the path into a FSRef of
> the directory:
> osError = FSMakeFSSpec (0,
> 0,
> currentPrefs.destPath,
> &localeFSSpec);
This is wrong. FSMakeFSSpec takes a path, but it's a :-separated path, not a
/-separated path, and it's limited to 255 characters, so you should just not use
that functionality for your purpose. Instead, look at FSPathMakeRef and
FSRefMakePath.
> Then, I use this FSSpec's vRefNum and parID, added to my fileName, to
> create the good FSSpec.
After you get the FSRef as I desribed above, you should use FSCreateFileUnicode
to create the file. That will allow you to use long filenames. However, if you
insist on sticking to the outdates FSSpec APIs, call
FSGetCatalogInfo to convert the parent FSRef to an FSSpec, and then use
FSMakeFSSpec to create the FSSpec for the file itself.
hth
meeroh
--
If this message helped you, consider buying an item
from my wish list: <http://web.meeroh.org/wishlist><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: problem creating a file (rather long) |
|
| Back to top |
|
 |  |
External

Since: Oct 22, 2003 Posts: 6
|
(Msg. 3) Posted: Thu Feb 26, 2004 3:54 pm
Post subject: Re: problem creating a file (rather long) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
hello,
first, thanks for your help.
Miro Jurisic wrote:
>
> CodeWarrior works fine for both Mac OS 9 and Mac OS X.
I have tried it, but never be able to generate an OSX app with codeWarrior 8.
> > folder. First little problem: this dialog displays itself with an "open"
> > label for the accept button, instead of the "choose" I want, and no "Open"
> > button to allow the user to navigate ???
>
> I believe this mislabeling is a known bug in Mac OS X 10.3 and will be fixed.
> The "Open" button is not used for folder navigation at all.
This is a difference between OS9 and OS X ? In my opinion, the Open button
was the navigation tool in OS 9 ?
>
> > To be clean, I store only the path of this directory in my prefs. I have
> > this path using a FSRef.
>
> You should probably be saving an alias, not a path.
To be able to survive to file/folder's name evolution ?
>
> This is wrong. FSMakeFSSpec takes a path, but it's a :-separated path, not a
> /-separated path, and it's limited to 255 characters, so you should just not use
> that functionality for your purpose. Instead, look at FSPathMakeRef and
> FSRefMakePath.
OK
>
>
> > Then, I use this FSSpec's vRefNum and parID, added to my fileName, to
> > create the good FSSpec.
>
> After you get the FSRef as I desribed above, you should use FSCreateFileUnicode
> to create the file. That will allow you to use long filenames. However, if you
> insist on sticking to the outdates FSSpec APIs, call
> FSGetCatalogInfo to convert the parent FSRef to an FSSpec, and then use
> FSMakeFSSpec to create the FSSpec for the file itself.
Actually I have tried to use only FSRef, which seems clearly more modern, until
I discover that Apple still use FSSpec, and only them (GRRRR), for some callbacks,
like
those allowing the user to chose a folder or a file. Or did I miss something ?
Thanks
Henri<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: problem creating a file (rather long) |
|
| Back to top |
|
 |  |
External

Since: May 10, 2004 Posts: 973
|
(Msg. 4) Posted: Thu Feb 26, 2004 8:34 pm
Post subject: Re: problem creating a file (rather long) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <403DDE60.38848BE6 DeleteThis @supelec.frNOSPAM>,
henri delebecque <henri.delebecque DeleteThis @supelec.frNOSPAM> wrote:
> > CodeWarrior works fine for both Mac OS 9 and Mac OS X.
>
> I have tried it, but never be able to generate an OSX app with codeWarrior 8.
I am sure you can get help here if you ask about specific problems.
> > > folder. First little problem: this dialog displays itself with an "open"
> > > label for the accept button, instead of the "choose" I want, and no
> > > "Open" button to allow the user to navigate ???
> >
> > I believe this mislabeling is a known bug in Mac OS X 10.3 and will be
> > fixed. The "Open" button is not used for folder navigation at all.
>
> This is a difference between OS9 and OS X ? In my opinion, the Open button
> was the navigation tool in OS 9 ?
I honestly don't remember.
> > > To be clean, I store only the path of this directory in my prefs. I have
> > > this path using a FSRef.
> >
> > You should probably be saving an alias, not a path.
>
> To be able to survive to file/folder's name evolution ?
Yes.
> Actually I have tried to use only FSRef, which seems clearly more modern,
> until I discover that Apple still use FSSpec, and only them (GRRRR), for some
> callbacks, like those allowing the user to chose a folder or a file. Or did I
> miss something ?
I am not aware of any Navigation services API which requires you to use FSSpecs
unless you are running on Mac OS 8.6 or older. Which callbacks are you referring
to?
meeroh
--
If this message helped you, consider buying an item
from my wish list: <http://web.meeroh.org/wishlist><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: problem creating a file (rather long) |
|
| Back to top |
|
 |  |
External

Since: Oct 22, 2003 Posts: 6
|
(Msg. 5) Posted: Fri Feb 27, 2004 1:17 pm
Post subject: Re: problem creating a file (rather long) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
hello,
Miro Jurisic wrote:
>
> > Actually I have tried to use only FSRef, which seems clearly more modern,
> > until I discover that Apple still use FSSpec, and only them (GRRRR), for some
> > callbacks, like those allowing the user to chose a folder or a file. Or did I
> > miss something ?
>
> I am not aware of any Navigation services API which requires you to use FSSpecs
> unless you are running on Mac OS 8.6 or older. Which callbacks are you referring
> to?
Since I use ProjectBuilder, I think that I use Mac OSX. Actually, Panther.
I have made a little mistake: the problem is not in navigating functions, but in
many function described in the File Manager Reference index:
locking/unlocking, opening data fork still use FSSpec.
Apple has done half the work. And its not the first example I see.
Yours<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: problem creating a file (rather long) |
|
| Back to top |
|
 |  |
External

Since: May 10, 2004 Posts: 973
|
(Msg. 6) Posted: Fri Feb 27, 2004 1:17 pm
Post subject: Re: problem creating a file (rather long) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <403F0B3E.A66882F8.RemoveThis@supelec.frNOSPAM>,
henri delebecque <henri.delebecque.RemoveThis@supelec.frNOSPAM> wrote:
> Since I use ProjectBuilder, I think that I use Mac OSX. Actually, Panther. I
> have made a little mistake: the problem is not in navigating functions, but
> in many function described in the File Manager Reference index:
> locking/unlocking, opening data fork still use FSSpec.
No, that's not true. More likely, the reference you are reading only lists the
original file manager APIs, not the FSRef APIs.
Locking is done by setting or clearing the
kFSNodeLockedBit in nodeFlags of FSCatalogInfo, using FSSetCatalogInfo:
FSRef file;
FSCatalogInfo info;
FSGetCatalogInfo(&file, kFSCatInfoNodeFlags, &info, 0, 0, 0);
info.nodeFlags |= kFSNodeLockedMask; // set locked bit
FSSetCatalogInfo(&file, kFSCatInfoNodeFlags, &info); // set file info
// or
info.nodeFlags &= ~kFSNodeLockedMask; // clear locked bit
FSSetCatalogInfo(&file, kFSCatInfoNodeFlags, &info); // set file info
Opening data fork is done using FSOpenFork:
FSRef file;
HFSUniStr255 forkName;
FSGetDataForkName(&forkName);
SInt16 fork;
FSOpenFork(&file, name.length, &name.unicode[0], permissions, &fork);
Error handling left as an exercise for the reader.
hth
meeroh
--
If this message helped you, consider buying an item
from my wish list: <http://web.meeroh.org/wishlist><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: problem creating a file (rather long) |
|
| Back to top |
|
 |  |
External

Since: Aug 23, 2003 Posts: 316
|
(Msg. 7) Posted: Fri Feb 27, 2004 10:11 pm
Post subject: Re: problem creating a file (rather long) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Thu, 26 Feb 2004, henri delebecque wrote:
> hello,
<snip>
>
> osError = NavGetDefaultDialogCreationOptions (&dialogOptions);
> dialogOptions.optionFlags = kNavDefaultNavDlogOptions; /*
> defaults options*/
> dialogOptions.optionFlags += kNavAllFilesInPopup; /* allows "all
> documents"*/
> dialogOptions.optionFlags -= kNavAllowStationery; /* no
> "Stationery"*/
> dialogOptions.optionFlags -= kNavAllowPreviews; /* no
> "Previews"*/
> dialogOptions.optionFlags -= kNavDontAddRecents; /* don't add
> Recents;*/
> dialogOptions.optionFlags -= kNavAllowMultipleFiles; /* unique
> selection;*/
>
In addition to what meeroh has said, you are probably not setting the
options you thing you are. kNavDontAddRecents isn't part of the default
options, so when you subtract it, funny stuff will happen. (in particular,
i get the final value of the options flag as being 0xffffc094 instead of
0x14).
It's much safer to use | etc... when setting or clearing flags,
Fred<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: problem creating a file (rather long) |
|
| Back to top |
|
 |  |
| Related Topics: | creating a transparent os-x icon - I am a novice mac programmer & i need to create an icon for my icon. But my problem in how to make a transparent icons. I have created a transparent image (TIFF) but how to convert into a Mac OSX icon?
Library for creating Charts and Graphs. - Hi, Does anyone knows where I can find a C/Carbon library for creating Charts and Graphs ? Any help is welcome... Thanks in advance, edeleur@euronet.nl
Creating local path from path with ':' seperators - heya, I've got a path like "Mac HD:Users:harpstein:" and I want to convert it to the real path of "/Users/harpstein" I've found the FileManager routine FSRefMakePath, but can't figure out how to create the FSRef from the path I ha...
OS X Reading & creating excel files from own app - Hello, I'm currently porting an old 68k classic application to a Carbon Mach-O application that reads and writes excel files. If I look at the old code I see the it uses OLE2 to read in the excel file and retrieve the contents of the fields etc. And th...
BOMArchiveHelper ignoring protections in ZIP file - We have a small Java tool that we have been distributing for 10.1 and 10.2 as a simple ZIP file because it is unpacked automatically and is ready to go. The user drags the tool wherever they want it. With 10.3, the default opener for ZIP files has become... |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|