Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: QTNewDataReferenceFromFullPathCFString returns -37



I think Scott's last response pointing me to a technical article
possibly answers my question but in case I'm doing something wrong....

To quote the article at http://developer.apple.com/qa/qa2005/qa1413.html
-

" Currently, the data reference APIs
(QTNewDataReferenceFromFullPathCFString, QTNewDataReferenceFromCFURL and
so on) may return an error for long file names or Unicode pathnames.
However, we plan to address these restrictions in a future version of
QuickTime."

The article goes on to say - " You should continue to use the QuickTime
data reference based APIs even if they do not work with long file names
or Unicode today because once these restrictions are lifted your code
will "just work" without any additional modifications."

Don't know what to make of the above but my code definitely does not
"just work" :-)

The code uses VC++ specific library functions and defines but here it is
anyway - 

// This function gets the dataset, groupname and moviename params passed
in // as the MFC CString type. The CString class supports Unicode and
has an //operator method (LPCTSTR) that will extract the string from the
object.
// I passed in "V:", "QTGrp", "Clip_12". The path is therefore
// V:\QTGrp\Clip_12\Clip_12.mov. I'm going to be creating this file. 
 // _MAX_PATH is 256. _TCHAR boils down to unsigned short (wchar_t)

OSErr myErr;
_TCHAR tmpPath[_MAX_PATH];
_stprintf(tmpPath, _T("%s\\%s\\%s\\%s.mov"), (LPCTSTR) dataSet,
(LPCTSTR) groupName, (LPCTSTR) movieName, (LPCTSTR) movieName );

_TCHAR op[_MAX_PATH] = {0};

DataReferenceRecord dataRef;

// Create a CFStringRef with the Unicode string. UniChar is also an
unsigned // short so should be compatible with tmpPath
CFStringRef pathstr = CFStringCreateWithCharacters(0, (UniChar*)tmpPath,
_MAX_PATH);

// This call returns the -37 badNamErr
myErr = QTNewDataReferenceFromFullPathCFString( pathstr,
kQTWindowsPathStyle, 0, &dataRef.dataRef, &dataRef.dataRefType);


if (myErr != noErr)
{
	_stprintf(op, _T("QTNewDataReferenceFromFullPathCFString err %d
"), 			myErr);
	OutputDebugString(op);
	// I actually throw an exception here and exit the function.
This is 	//removed for clarity
}

// Create storage for the file
DataHandler dh = nil;
myErr = CreateMovieStorage( dataRef.dataRef, dataRef.dataRefType,
			       'appl', smCurrentScript, 
				   createMovieFileDeleteCurFile,
				   &dh, nil);
if (myErr != noErr)
{
	_stprintf(op, _T("QTNewDataReferenceFromFullPathCFString err %d
"), 			myErr);
	OutputDebugString(op);
}

// put the movie I have been creating into the storage. m_qtMovie is my
 // Movie (reference file)

myErr = PutMovieIntoStorage(m_qtMovie, dh, 0, MAX_SIZE);


Thanks,
Deepak


-----Original Message-----
From: Brian Pietsch [mailto:email@hidden] 
Sent: Friday, June 02, 2006 10:29 AM
To: Paul Deepak
Cc: email@hidden
Subject: Re: QTNewDataReferenceFromFullPathCFString returns -37

Can you post a short piece of actual source code along with a  
specific path that you have tried and fails as described.  That's the  
easiest way for us to tell what you're doing wrong.  Errors like this  
are usually due to a subtle coding error which is lost in translation  
when you only post pseudo-code.

Brian


On Jun 1, 2006, at 5:36 PM, Paul Deepak wrote:

> Hi all,
>
> Using Windows QT SDK ver 7 and Visual Studio 7.
>
> QTNewDataReferenceFromFullPathCFString() does not seem to work when I
> pass it a data ref to a Unicode path. It may be as simple a path as
> "c:\somedir\somesubdir\myfile.mov". I tried with Chinese chars too.  
> The
> code is as follows -
>
> // tmpPath is a wchar_t array of size SOME_SIZE. Wchar_t is a  
> typedef'ed
> as // an unsigned short in my VC++ compiler.
>
> DataReferenceRecord dataRef;
> CFStringRef pathstr = CFStringCreateWithCharacters(0, (UniChar*) 
> tmpPath,
> SOME_SIZE);
>
> QTNewDataReferenceFromFullPathCFString( pathstr,  
> kQTWindowsPathStyle, 0,
> &dataRef.dataRef, &dataRef.dataRefType);
>
> QTNewDataReferenceFromFullPathCFString() returns an OSErr of -37 which
> seems to be defined as -
>
> bdNamErr                      = -37,  /*there may be no bad names  
> in the
> final system!*/ in macerrors.h
>
> I have tried the following -
>
> 1. Used kQTNativeDefaultPathStyle
> 2. Used CFStringGetCharactersPtr() after the call to
> CFStringCreateWithCharacters() to verify the buffer contents and my
> debugger IDE recognized the string so it apparently is good ?
>
> Please help. I'm not sure what to try next.
>
> Thanks.
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> QuickTime-API mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/quicktime-api/bpietsch% 
> 40apple.com
>
> This email sent to email@hidden



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.