Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Strange Filenames

Strange Filenames
Thread Tools
Junior Member
Join Date: Jul 2002
Location: Australia
Status: Offline
Reply With Quote
Jul 29, 2002, 09:05 AM
 
The following code opens up an "Open Dialog" window and the user selects a file then the filename gets inserted into a text box. Though there is a problem.... the filename's have ununsual characters.. EG.. ('text.txt' will be 'text.txt™pw™')...

Can anyone see any fault in the follwing code:

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">void Open_Dialog()
{
int count=1;

AEDesc defaultLocation;
NavReplyRecord reply;
NavDialogOptions dialogOptions;

NavGetDefaultDialogOptions ( &amp;dialogOptions );
NavGetFile ( &amp;defaultLocation, &amp;reply, &amp;dialogOptions, nil, nil, nil, NULL, nil );

while( count == 1 )
{
AEKeyword theKeyword;
DescType actualType;
Size actualSize;
FSSpec documentFSSpec;

AEGetNthPtr(&amp;(reply.selection), 1, typeFSS, &amp;theKeyword, &amp;actualType, &amp;documentFSSpec, sizeof(documentFSSpec), &amp;actualSize);

Display_Filename( documentFSSpec.name );

count++;
}
}

void Display_Filename( StrFileName Filename )
{
CFStringRef Output;

ControlRef Text1;
ControlID Text1ID;

Text1ID.signature = 'Matt';
Text1ID.id = 131;

GetControlByID( Window, &amp;Text1ID, &amp;Text1 );

Output = CFStringCreateWithFormat(NULL, NULL, CFSTR(&quot;%s&quot, Filename);

SetControlData( Text1, 0, kControlEditTextCFStringTag, sizeof(CFStringRef), &amp;Output );

DrawOneControl( Text1 );
}</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jul 29, 2002, 02:25 PM
 
At a guess, you're mixing pascal strings (first byte is length, followed by length number of characters) with c strings (NULL-terminated array of characters).
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:16 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2