VFile *VProcess::RetainFile( EFolderKind inPrimarySelector, const VString& inFileName, EFolderKind inSecondarySelector) const { VFile *file = NULL; VFolder *parent = RetainFolder( inPrimarySelector); if (testAssert( parent != NULL)) { file = new VFile( *parent, inFileName); if ( (file != NULL) && !file->Exists()) ReleaseRefCountable( &file); } ReleaseRefCountable( &parent); if ( (file == NULL) && (inSecondarySelector != 0) ) { parent = RetainFolder( inSecondarySelector); if ( (parent != NULL) && parent->Exists()) { file = new VFile( *parent, inFileName); if ( (file != NULL) && !file->Exists()) ReleaseRefCountable( &file); } ReleaseRefCountable( &parent); } return file; }
VError VFolder::CreateRecursive(bool inMakeWritableByAll) { VError err = VE_OK; if ( !fFolder.Exists( true) ) { VFolder *parent = RetainParentFolder(); if ( parent ) { err = parent->CreateRecursive(inMakeWritableByAll); parent->Release(); if ( err == VE_OK ) { err = Create(); #if !VERSION_LINUX if ((err == VE_OK) && inMakeWritableByAll) { err = MakeWritableByAll(); } #endif } } else { err = Create(); #if !VERSION_LINUX if ((err == VE_OK) && inMakeWritableByAll) { err = MakeWritableByAll(); } #endif } } return err; }
VFolder* VRIAServerSolution::RetainFolder() const { VFolder *folder = NULL; if (fDesignSolution != NULL) { VProjectItem *item = fDesignSolution->GetSolutionFileProjectItem(); if (item != NULL) { VFilePath path; item->GetFilePath( path); path = path.ToFolder(); if (path.IsFolder()) { folder = new VFolder( path); if (folder != NULL && !folder->Exists()) { folder->Release(); folder = NULL; } } } } return folder; }
VError VArchiveStream::AddFolder( VFilePath &inFileFolder ) { VError result = VE_STREAM_CANNOT_FIND_SOURCE; VFolder *folder = new VFolder(inFileFolder); result = AddFolder( folder ); folder->Release(); return result; }
VError XMacFileSystemNotification::StartWatchingForChanges( const VFolder &inFolder, VFileSystemNotifier::EventKind inKindFilter, VFileSystemNotifier::IEventHandler *inHandler, sLONG inLatency ) { // We need to get the folder's path into an array for us to pass along to the OS call. VString posixPathString; inFolder.GetPath( posixPathString, FPS_POSIX); VStringConvertBuffer buffer( posixPathString, VTC_UTF_8); std::string posixPath( buffer.GetCPointer()); CFStringRef pathRef = posixPathString.MAC_RetainCFStringCopy(); CFArrayRef pathArray = CFArrayCreate( NULL, (const void **)&pathRef, 1, NULL ); FSEventStreamContext context = { 0 }; // The latency the user passed us is expressed in milliseconds, but the OS call requires the latency to be // expressed in seconds. CFTimeInterval latency = (inLatency / 1000.0); // Now we can make our change data object XMacChangeData *data = new XMacChangeData( inFolder.GetPath(), posixPath, inKindFilter, VTask::GetCurrent(), inHandler, this); context.info = data; data->fStreamRef = FSEventStreamCreate( NULL, &FSEventCallback, &context, pathArray, kFSEventStreamEventIdSinceNow, latency, kFSEventStreamCreateFlagNone ); if (data->fStreamRef == NULL) { CFRelease( pathArray ); CFRelease( pathRef ); ReleaseRefCountable( &data); return MAKE_NATIVE_VERROR( errno ); } // We also need to take an initial snapshot of the directory for us to compare again CreateDirectorySnapshot( posixPath, data->fSnapshot, true ); // Now we can add the data object we just made to our list fOwner->PushChangeData( data); // Next, we can schedule this to run on the main event loop FSEventStreamScheduleWithRunLoop( data->fStreamRef, CFRunLoopGetMain(), kCFRunLoopDefaultMode ); CFRelease( pathArray ); CFRelease( pathRef ); // Now that we've scheduled the stream to run on a helper thread, all that is left is to // start executing the stream VError err; if (FSEventStreamStart( data->fStreamRef )) { err = VE_OK; } else { err = MAKE_NATIVE_VERROR( errno ); } ReleaseRefCountable( &data); return err; }
VError VProjectItemFolder::_MoveTo(const VFolder& srcFolder, VFolder& destFolder) { VError err = VE_OK; if (!destFolder.Exists()) err = destFolder.CreateRecursive(); else err = VE_UNKNOWN_ERROR; // TO DO ce n'est pas vrai : mais c'est pour le moment : 011008 // que faire : ecraser, fusionner, on attends les specs ! if (err == VE_OK) { for (VFolderIterator it_folder(&srcFolder, FI_WANT_FOLDERS | FI_WANT_INVISIBLES); it_folder.IsValid() && err == VE_OK; ++it_folder) { VFolder srcNewFolder(it_folder.Current()->GetPath()); VString srcNewFolderName; srcNewFolder.GetName(srcNewFolderName); VString destNewFolderPath; destFolder.GetPath(destNewFolderPath); destNewFolderPath += srcNewFolderName; destNewFolderPath += FOLDER_SEPARATOR; VFolder destNewFolder(destNewFolderPath); err = _MoveTo(srcNewFolder, destNewFolder); } for (VFileIterator it_file(&srcFolder, FI_WANT_FILES | FI_WANT_INVISIBLES); it_file.IsValid() && err == VE_OK; ++it_file) { VFile srcNewFile(it_file.Current()->GetPath()); VString srcNewFileName; srcNewFile.GetName(srcNewFileName); VString destNewFilePath; destFolder.GetPath(destNewFilePath); destNewFilePath += srcNewFileName; VFile destNewFile(destNewFilePath); VProjectItemFile projectItemFile; VURL srcURL = VURL(srcNewFile.GetPath()); VURL destURL = VURL(destNewFile.GetPath()); projectItemFile.MoveTo(srcURL, destURL); } } if (err == VE_OK) { err = srcFolder.Delete(true); } return err; }
VError XWinFolder::Move( const VFolder& inNewParent, VFolder** outFolder ) const { XBOX::VString name; VFilePath newPath( inNewParent.GetPath() ); DWORD winErr; if (newPath.IsValid()) { VString name; fOwner->GetName(name); newPath.ToSubFolder(name); XWinFullPath oldWinPath( fOwner->GetPath() ); XWinFullPath newWinPath( newPath ); winErr = ::MoveFileW( oldWinPath, newWinPath) ? 0 : ::GetLastError(); } else { winErr = ERROR_INVALID_NAME; } if (outFolder) { *outFolder = (winErr == 0) ? new VFolder( newPath) : NULL; } return MAKE_NATIVE_VERROR( winErr); }
VError VProjectItemFolder::GetModificationTime( VTime& outModificationTime) const { VError err = VE_OK; VFolder *folder = RetainFolder(); if (folder != NULL) { err = folder->GetTimeAttributes( &outModificationTime, NULL, NULL); ReleaseRefCountable( &folder); } else { err = VE_FOLDER_NOT_FOUND; } return err; }
VFolder::VFolder( const VFolder& inParentFolder, const VString& inFolderName) { fPath = inParentFolder.GetPath(); xbox_assert( fPath.IsFolder()); fPath.ToSubFolder( inFolderName); xbox_assert( fPath.IsFolder()); fFolder.Init( this); }
VFolder* VRIAServerSolution::RetainLogFolder( bool inCreateIfNotExists) const { VFolder *folder = NULL; if (fDesignSolution != NULL) { VProjectItem *item = fDesignSolution->GetSolutionFileProjectItem(); if (item != NULL) { VFilePath path; item->GetFilePath( path); path = path.ToFolder(); path.ToSubFolder( L"Logs"); folder = new VFolder( path); if (folder != NULL && !folder->Exists() && inCreateIfNotExists) folder->Create(); } } return folder; }
VError VFolder::CopyTo( const VFolder& inDestinationFolder, VFolder **outFolder, FileCopyOptions inOptions) const { VError err = VE_OK; VFolder *folder = NULL; if (IsSameFolder( &inDestinationFolder) || inDestinationFolder.GetPath().IsChildOf( GetPath())) { StThrowFileError errThrow( this, VE_CANNOT_COPY_ON_ITSELF); errThrow->SetString( "destination", inDestinationFolder.GetPath().GetPath()); err = errThrow.GetError(); } else { VString name; GetName( name); folder = new VFolder( inDestinationFolder, name); if (folder != NULL) { if ( ( (inOptions & FCP_Overwrite) != 0) && folder->Exists() ) err = folder->Delete( true); if (err == VE_OK) err = CopyContentsTo( *folder, inOptions); } else { err = VE_MEMORY_FULL; } } if (outFolder != NULL) { *outFolder = folder; folder = NULL; } ReleaseRefCountable( &folder); return err; }
VError XWinFileSystemNotification::StartWatchingForChanges( const VFolder &inFolder, VFileSystemNotifier::EventKind inKindFilter, VFileSystemNotifier::IEventHandler *inHandler, sLONG inLatency ) { VString path; inFolder.GetPath( path ); VError err = VE_OK; // Now that we know we need to care about this folder, let's see if we can create an entry for it. First, // we will try to open a handle to the folder. HANDLE hFolder = ::CreateFileW( path.GetCPointer(), FILE_LIST_DIRECTORY | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL ); if (hFolder == INVALID_HANDLE_VALUE) { // We were unable to open the folder, so we need to bail out return MAKE_NATIVE_VERROR( ::GetLastError() ); } // launch our task if not already there LaunchTaskIfNecessary(); // Now that we've opened the folder handle, we can add an entry to our watch list XWinChangeData *data = new XWinChangeData( inFolder.GetPath(), inKindFilter, VTask::GetCurrent(), inHandler, this); data->fFolderHandle = hFolder; data->fLatency = inLatency; data->fOverlapped.hEvent = ::CreateEvent( NULL, true, false, NULL ); data->fTimer = NULL; if (inLatency) data->fTimer = ::CreateWaitableTimer( NULL, FALSE, NULL ); // Add the new data to our list of things to watch for fOwner->PushChangeData( data ); WatchForChanges( data ); ReleaseRefCountable( &data); return VE_OK; }
VError VFolder::CopyContentsTo( const VFolder& inDestinationFolder, FileCopyOptions inOptions) const { VError err = VE_OK; if (!inDestinationFolder.Exists()) { // this easy case should be handled by system implementation err = inDestinationFolder.Create(); } else if (IsSameFolder( &inDestinationFolder) || inDestinationFolder.GetPath().IsChildOf( GetPath())) { StThrowFileError errThrow( this, VE_CANNOT_COPY_ON_ITSELF); errThrow->SetString( "destination", inDestinationFolder.GetPath().GetPath()); err = errThrow.GetError(); } if (err == VE_OK) { bool ok = true; for( VFolderIterator folderIterator( this, FI_WANT_FOLDERS | FI_WANT_INVISIBLES) ; folderIterator.IsValid() && ok ; ++folderIterator) { VError err2 = folderIterator->CopyTo( inDestinationFolder, NULL, inOptions); if (err == VE_OK) err = err2; ok = (err == VE_OK) | ((inOptions & FCP_ContinueOnError) != 0); } for( VFileIterator fileIterator( this, FI_WANT_FILES | FI_WANT_INVISIBLES) ; fileIterator.IsValid() && ok ; ++fileIterator) { VError err2 = fileIterator->CopyTo( inDestinationFolder, NULL, inOptions); if (err == VE_OK) err = err2; ok = (err == VE_OK) | ((inOptions & FCP_ContinueOnError) != 0); } } return err; }
XBOX::VError VProjectItemFolder::Rename( const XBOX::VString& inNewName) { if (fOwner == NULL) return VE_FOLDER_CANNOT_RENAME; VFilePath path; if (!fOwner->GetFilePath( path)) return VE_FOLDER_CANNOT_RENAME; VFolder *newFolder = NULL; VFolder folder( path); VError err = folder.Rename( inNewName, &newFolder); if (err == VE_OK && newFolder != NULL) { VString folderName; newFolder->GetName( folderName); fOwner->SetName( folderName); // sc 26/09/2011, WAK0073011 fOwner->SetDisplayName( folderName); if (fOwner->HasRelativePath()) { folderName += FOLDER_SEPARATOR; fOwner->SetRelativePath( folderName); } else { VFilePath path; newFolder->GetPath( path); fOwner->SetURL( VURL( path)); } } if (err != VE_OK) err = VE_FOLDER_CANNOT_RENAME; return err; }
VError VArchiveUnStream::ProceedFile() { VError result = VE_OK; bool userAbort = false; uLONG8 partialByteCount = 0; if ( fCallBack ) fCallBack(CB_OpenProgress,partialByteCount,fTotalByteCount,userAbort); VFileDesc *fileDesc = NULL; VSize bufferSize = 1024*1024; char *buffer = new char[bufferSize]; for ( uLONG i = 0; i < fFileCatalog.size() && result == VE_OK; i++ ) { fileDesc = NULL; if ( fStream->GetLong() == 'Fdat' ) { if ( fFileCatalog[i]->GetExtractFlag() ) { VFolder *parentFolder = fFileCatalog[i]->GetFile()->RetainParentFolder(); if ( parentFolder ) { result = parentFolder->CreateRecursive(); parentFolder->Release(); } if ( result == VE_OK ) { result = fFileCatalog[i]->GetFile()->Open( FA_SHARED, &fileDesc, FO_CreateIfNotFound); #if VERSIONMAC fFileCatalog[i]->GetFile()->MAC_SetKind(fFileCatalog[i]->GetKind()); fFileCatalog[i]->GetFile()->MAC_SetCreator(fFileCatalog[i]->GetCreator()); #endif } } if ( result == VE_OK ) { result = _ExtractFile( fFileCatalog[i], fileDesc, buffer, bufferSize, partialByteCount ); delete fileDesc; } if ( result == VE_OK ) { fileDesc = NULL; if ( fStream->GetLong() == 'Frez' ) { if ( fFileCatalog[i]->GetExtractFlag() ) { #if VERSIONMAC result = fFileCatalog[i]->GetFile()->Open( FA_SHARED, &fileDesc, FO_OpenResourceFork); #endif } if ( result == VE_OK ) { result = _ExtractFile( fFileCatalog[i], fileDesc, buffer, bufferSize, partialByteCount ); delete fileDesc; } } else { result = VE_STREAM_BAD_SIGNATURE; } } } else { result = VE_STREAM_BAD_SIGNATURE; } } delete[] buffer; if ( fCallBack ) fCallBack(CB_CloseProgress,partialByteCount,fTotalByteCount,userAbort); return result; }
//ACI0078887 23rd Nov 2012, O.R., always specify folder used for computing relative path of entry in TOC VError VArchiveStream::_WriteCatalog( const VFile* inFile, const XBOX::VFilePath& inSourceFolder,const VString &inExtraInfo, uLONG8 &ioTotalByteCount ) { VString fileInfo; VStr8 slash("/"); VStr8 extra("::"); VStr8 folderSep(XBOX::FOLDER_SEPARATOR); VError result = VE_INVALID_PARAMETER; XBOX::VString savedExtraInfo = inExtraInfo; //ACI0078887 23rd Nov 2012, O.R., compute relative path using the specified source folder //don't assume that extra info carries relative folder info //ACI0078887 23rd Nov 2012, O.R., compute relative path using the specified source folder //don't assume that extra info carries relative folder info if (savedExtraInfo == PRESERVE_PARENT_OPTION) { //this is a bogus extra info that we use internally so we need to clear it so that it is not saved into //the archive. //This options means that the file will have to be restored in with its parent directory preserved. savedExtraInfo.Clear(); VFolder *folder = inFile->RetainParentFolder(); VString fileName; folder->GetName(fileInfo); // folder name can be a drive letter like Z: fileInfo.Exchange( (UniChar) ':', (UniChar) '_'); inFile->GetName(fileName); fileInfo += slash; fileInfo += fileName; fileInfo.Insert( slash, 1 ); folder->Release(); result = VE_OK; } else { if(testAssert(inFile->GetPath().GetRelativePath(inSourceFolder,fileInfo))) { result = VE_OK; fileInfo.Insert( FOLDER_SEPARATOR, 1); } } if(result == VE_OK) { fileInfo.Exchange(folderSep ,slash, 1, 255); if ( fileInfo.GetUniChar(1) == '/' ) fileInfo.Insert( '.', 1 ); fileInfo += extra; fileInfo += savedExtraInfo; result = fStream->PutLong('file'); if ( result == VE_OK ) { result = fileInfo.WriteToStream(fStream); } if ( result == VE_OK ) { sLONG8 fileSize = 0; inFile->GetSize(&fileSize); fStream->PutLong8(fileSize); ioTotalByteCount += fileSize; #if VERSIONWIN || VERSION_LINUX /* rez file size */ fStream->PutLong8(0); /* no file kind or creator under Windows */ fStream->PutLong(0); /* kind */ fStream->PutLong(0); /* creator */ #elif VERSIONMAC inFile->GetResourceForkSize(&fileSize); fStream->PutLong8(fileSize); ioTotalByteCount += fileSize; OsType osType; inFile->MAC_GetKind( &osType ); result = fStream->PutLong( osType ); inFile->MAC_GetCreator( &osType ); result = fStream->PutLong( osType ); #endif } } return result; }
VFolder *VProcess::RetainProductSystemFolder( ESystemFolderKind inSelector, bool inCreateFolderIfNotFound) const { VFolder *folder = NULL; bool allUsers; bool useProductSubFolder; ESystemFolderKind currentUserFolder; switch( inSelector) { case eFK_UserDocuments: case eFK_Temporary: allUsers = true; useProductSubFolder = true; break; case eFK_CommonPreferences: currentUserFolder = eFK_UserPreferences; allUsers = true; useProductSubFolder = true; break; case eFK_CommonApplicationData: currentUserFolder = eFK_UserApplicationData; allUsers = true; useProductSubFolder = true; break; case eFK_CommonCache: currentUserFolder = eFK_UserCache; allUsers = true; useProductSubFolder = true; break; case eFK_UserPreferences: case eFK_UserApplicationData: case eFK_UserCache: allUsers = false; useProductSubFolder = true; break; default: allUsers = false; useProductSubFolder = false; break; } if (useProductSubFolder) { VFolder *parent = VFolder::RetainSystemFolder( inSelector, inCreateFolderIfNotFound); if (parent != NULL) { VError err; VString folderName; GetProductName( folderName); // accepte un alias VString aliasName( folderName); #if VERSIONWIN aliasName += ".lnk"; #endif VFile aliasFile( *parent, aliasName); if (aliasFile.Exists() && aliasFile.IsAliasFile()) { VFilePath target; err = aliasFile.ResolveAlias( target); if ( (err == VE_OK) && target.IsFolder() ) { folder = new VFolder( target); } } if (folder == NULL) { folder = new VFolder( *parent, folderName); } if (!folder->Exists()) { if (inCreateFolderIfNotFound) { if (allUsers) { // drop errors if we can retry in current user home directory StErrorContextInstaller context( false); err = folder->CreateRecursive( allUsers); } else { err = folder->CreateRecursive( allUsers); } if (err != VE_OK) { ReleaseRefCountable( &folder); // si on nous a demande de creer dans "all users", on ressaie dans le dossier de l'utilisateur courant if (allUsers) { folder = RetainProductSystemFolder( currentUserFolder, inCreateFolderIfNotFound); } } } else { ReleaseRefCountable( &folder); } } } ReleaseRefCountable( &parent); } else { folder = VFolder::RetainSystemFolder( inSelector, inCreateFolderIfNotFound); } return folder; }
VFolder* VProcess::RetainFolder( VProcess::EFolderKind inSelector) const { VFolder* folder = NULL; switch (inSelector) { case eFS_Executable: folder = new VFolder( GetExecutableFolderPath()); break; case eFS_Bundle: #if VERSIONWIN || VERSION_LINUX folder = new VFolder( GetExecutableFolderPath()); #elif VERSIONMAC folder = new VFolder( GetExecutableFolderPath().ToParent().ToParent()); #endif break; case eFS_Resources: { #if VERSIONWIN || VERSION_LINUX VFolder *parent = new VFolder( GetExecutableFolderPath()); #elif VERSIONMAC VFolder *parent = new VFolder( GetExecutableFolderPath().ToParent()); // Contents #endif if (parent != NULL) folder = new VFolder( *parent, CVSTR( "Resources")); ReleaseRefCountable( &parent); break; } case eFS_InfoPlist: { // Resources folder on windows. // Contents folder on mac. #if VERSIONWIN || VERSION_LINUX folder = RetainFolder( eFS_Resources); #elif VERSIONMAC folder = new VFolder( GetExecutableFolderPath().ToParent()); #endif break; } case eFS_NativeComponents: { #if VERSIONWIN || VERSION_LINUX folder = new VFolder( GetExecutableFolderPath().ToSubFolder( CVSTR( "Native Components"))); #elif VERSIONMAC folder = new VFolder( GetExecutableFolderPath().ToParent().ToSubFolder( CVSTR( "Native Components"))); #endif // in debug mode the "Native Components" might be next the bundle folder to be shared among mono, server, studio, server #if VERSIONDEBUG if ( (folder == NULL) || !folder->Exists() ) { ReleaseRefCountable( &folder); #if VERSIONWIN || VERSION_LINUX folder = new VFolder( GetExecutableFolderPath().ToParent().ToSubFolder( CVSTR( "Native Components"))); #elif VERSIONMAC folder = new VFolder( GetExecutableFolderPath().ToParent().ToParent().ToParent().ToSubFolder( CVSTR( "Native Components"))); #endif } #endif break; } case eFS_DTDs: { VFolder *parent = RetainFolder( eFS_Resources); if (parent != NULL) folder = new VFolder( *parent, CVSTR( "DTD")); ReleaseRefCountable( &parent); break; } case eFS_XSDs: { VFolder *parent = RetainFolder( eFS_Resources); if (parent != NULL) folder = new VFolder( *parent, CVSTR( "XSD")); ReleaseRefCountable( &parent); break; } case eFS_XSLs: { VFolder *parent = RetainFolder( eFS_Resources); if (parent != NULL) folder = new VFolder( *parent, CVSTR( "XSL")); ReleaseRefCountable( &parent); break; } default: break; } return folder; }
/* static */ DialectCode VComponentManager::GetLocalizationLanguage(VFolder * inLocalizationResourcesFolder,bool inGotoResourceFolder) { DialectCode sResult = XBOX::DC_NONE; // sc 19/05/2008 was XBOX::DC_ENGLISH_US VFolder * localizationResourcesFolder = NULL; if(testAssert(inLocalizationResourcesFolder != NULL && inLocalizationResourcesFolder->Exists())) { if (inGotoResourceFolder) { XBOX::VFilePath componentOrPluginFolderPath = inLocalizationResourcesFolder->GetPath(); componentOrPluginFolderPath.ToSubFolder(CVSTR("Contents")).ToSubFolder(CVSTR("Resources")); localizationResourcesFolder = new XBOX::VFolder(componentOrPluginFolderPath); } else { localizationResourcesFolder = inLocalizationResourcesFolder; localizationResourcesFolder->Retain(); } bool englishFolderDetected = false; XBOX::DialectCode dialectCode = XBOX::DC_NONE; //Detect what is the favorite language of the OS/App #if VERSIONWIN LCID lcid = ::GetUserDefaultLCID(); XBOX::DialectCode currentDialectCode = (XBOX::DialectCode)LANGIDFROMLCID(lcid); #elif VERSION_LINUX //jmo - Be coherent with code in VIntlMgr.cpp XBOX::DialectCode currentDialectCode=XBOX::DC_ENGLISH_US; // Postponed Linux Implementation ! #else CFBundleRef bundle = ::CFBundleGetMainBundle(); XBOX::DialectCode currentDialectCode = XBOX::DC_ENGLISH_US; if ( bundle != nil ){ CFArrayRef array_ref = ::CFBundleCopyBundleLocalizations(bundle); if (array_ref != nil){ CFArrayRef usedLanguages = ::CFBundleCopyPreferredLocalizationsFromArray(array_ref); CFStringRef cfPrimaryLanguage = (CFStringRef)CFArrayGetValueAtIndex(usedLanguages, 0); XBOX::VString xboxPrimaryLanguage; xboxPrimaryLanguage.MAC_FromCFString(cfPrimaryLanguage); ::CFRelease(usedLanguages); if(!XBOX::VIntlMgr::GetDialectCodeWithISOLanguageName(xboxPrimaryLanguage, currentDialectCode)) if(!XBOX::VIntlMgr::GetDialectCodeWithRFC3066BisLanguageCode(xboxPrimaryLanguage, currentDialectCode)) currentDialectCode = XBOX::DC_ENGLISH_US; CFRelease(array_ref); } } #endif //Try to see if we have this language. If not, take english for ( XBOX::VFolderIterator folderIter( localizationResourcesFolder ); folderIter.IsValid() && currentDialectCode != dialectCode ; ++folderIter ) { XBOX::VString folderName; folderIter->GetName(folderName); uLONG posStr = folderName.Find(CVSTR(".lproj"), 1, false); if ( posStr > 0 ) { folderName.Remove(posStr, folderName.GetLength() - posStr + 1); if( XBOX::VIntlMgr::GetDialectCodeWithRFC3066BisLanguageCode(folderName, dialectCode ) || XBOX::VIntlMgr::GetDialectCodeWithISOLanguageName(folderName, dialectCode)){ if(dialectCode == XBOX::DC_ENGLISH_US) englishFolderDetected = true; if(currentDialectCode == dialectCode) sResult = dialectCode; } } } if ( sResult == XBOX::DC_NONE ){ if ( englishFolderDetected ) sResult = XBOX::DC_ENGLISH_US; else sResult = dialectCode; } ReleaseRefCountable(&localizationResourcesFolder); } return sResult; }
VValueSingle *JS4D::ValueToVValue( ContextRef inContext, ValueRef inValue, ValueRef *outException) { if (inValue == NULL) return NULL; VValueSingle *value; JSType type = JSValueGetType( inContext, inValue); switch( type) { case kJSTypeUndefined: case kJSTypeNull: value = NULL; //new VEmpty; break; case kJSTypeBoolean: value = new VBoolean( JSValueToBoolean( inContext, inValue)); break; case kJSTypeNumber: value = new VReal( JSValueToNumber( inContext, inValue, outException)); break; case kJSTypeString: { JSStringRef jsString = JSValueToStringCopy( inContext, inValue, outException); if (jsString != NULL) { VString *s = new VString; size_t length = JSStringGetLength( jsString); UniChar *p = (s != NULL) ? s->GetCPointerForWrite( length) : NULL; if (p != NULL) { ::memcpy( p, JSStringGetCharactersPtr( jsString), length * sizeof( UniChar)); s->Validate( length); value = s; } else { delete s; value = NULL; } JSStringRelease( jsString); } else { value = NULL; } break; } case kJSTypeObject: { if (ValueIsInstanceOf( inContext, inValue, CVSTR( "Date"), outException)) { VTime *time = new VTime; if (time != NULL) { JSObjectRef dateObject = JSValueToObject( inContext, inValue, outException); DateObjectToVTime( inContext, dateObject, *time, outException); value = time; } else { value = NULL; } } else if (JSValueIsObjectOfClass( inContext, inValue, VJSFolderIterator::Class())) { value = NULL; JS4DFolderIterator* container = static_cast<JS4DFolderIterator*>(JSObjectGetPrivate( JSValueToObject( inContext, inValue, outException) )); if (testAssert( container != NULL)) { VFolder* folder = container->GetFolder(); if (folder != NULL) { VString *s = new VString; if (s != NULL) folder->GetPath( *s, FPS_POSIX); value = s; } } } else if (JSValueIsObjectOfClass( inContext, inValue, VJSFileIterator::Class())) { value = NULL; JS4DFileIterator* container = static_cast<JS4DFileIterator*>(JSObjectGetPrivate( JSValueToObject( inContext, inValue, outException) )); if (testAssert( container != NULL)) { VFile* file = container->GetFile(); if (file != NULL) { VString *s = new VString; if (s != NULL) file->GetPath( *s, FPS_POSIX); value = s; } } } else if (JSValueIsObjectOfClass( inContext, inValue, VJSBlob::Class())) { // remember File inherits from Blob so one must check File before Blob VJSBlob::PrivateDataType* blobValue = static_cast<VJSBlob::PrivateDataType*>(JSObjectGetPrivate( JSValueToObject( inContext, inValue, outException) )); if (testAssert( blobValue != NULL)) { VJSDataSlice *slice = blobValue->RetainDataSlice(); VBlobWithPtr *blob = new VBlobWithPtr; if ( (blob != NULL) && (slice != NULL) && (slice->GetDataSize() > 0) ) { if (blob->PutData( slice->GetDataPtr(), slice->GetDataSize()) != VE_OK) { delete blob; blob = NULL; } } value = blob; ReleaseRefCountable( &slice); } else { value = NULL; } } #if !VERSION_LINUX // Postponed Linux Implementation ! else if (JSValueIsObjectOfClass( inContext, inValue, VJSImage::Class())) { VJSImage::PrivateDataType* piccontainer = static_cast<VJSImage::PrivateDataType*>(JSObjectGetPrivate( JSValueToObject( inContext, inValue, outException) )); if (testAssert( piccontainer != NULL)) { VPicture *vpic = piccontainer->GetPict(); value = (vpic != NULL) ? new VPicture(*vpic) : NULL; } else { value = NULL; } } #endif else { value = NULL; } break; } default: value = NULL; break; } return value; }
VError XWinFolder::RetainSystemFolder( ESystemFolderKind inFolderKind, bool inCreateFolder, VFolder **outFolder ) { VString folderPath; UniChar path[4096]; size_t maxLength = sizeof( path)/sizeof( UniChar); path[maxLength-2]=0; VFolder* sysFolder = NULL; DWORD winErr = ERROR_PATH_NOT_FOUND; switch( inFolderKind) { case eFK_Executable: { DWORD pathLength = ::GetModuleFileNameW( NULL, path, (DWORD) maxLength); if (testAssert( pathLength != 0 && !path[maxLength-2])) { folderPath.FromUniCString( path ); VFile exeFile( folderPath ); sysFolder = exeFile.RetainParentFolder(); winErr = 0; } break; } case eFK_Temporary: { DWORD length = ::GetTempPathW( (DWORD) maxLength, path); if ( (length > 0) && (length <= maxLength) && !path[maxLength-2]) { DWORD size = ::GetLongPathNameW( path, NULL, 0); if (size > 0) { UniChar *p = folderPath.GetCPointerForWrite( size-1); if (p != NULL) { DWORD result = ::GetLongPathNameW( path, p, size); if (result == 0) winErr = GetLastError(); else winErr = 0; folderPath.Validate( result); sysFolder = new VFolder( folderPath ); } } } break; } default: { int type; switch( inFolderKind) { case eFK_UserDocuments: type = CSIDL_PERSONAL; break; case eFK_CommonPreferences: type = CSIDL_COMMON_APPDATA; break; case eFK_UserPreferences: type = CSIDL_APPDATA; break; case eFK_CommonApplicationData: type = CSIDL_COMMON_APPDATA; break; case eFK_UserApplicationData: type = CSIDL_APPDATA; break; case eFK_CommonCache: type = CSIDL_COMMON_APPDATA; break; case eFK_UserCache: type = CSIDL_LOCAL_APPDATA; break; default: xbox_assert( false); type = CSIDL_APPDATA; break; } HRESULT result = ::SHGetFolderPathW( NULL, type, NULL, SHGFP_TYPE_CURRENT, path); if ( result == S_OK || result == S_FALSE ) // S_FALSE means The CSIDL is valid, but the folder does not exist. { folderPath.FromUniCString( path); if (folderPath[folderPath.GetLength()-1] != FOLDER_SEPARATOR) folderPath += FOLDER_SEPARATOR; sysFolder = new VFolder( folderPath ); winErr = 0; } break; } } if ( (sysFolder != NULL) && !sysFolder->Exists() ) { if (inCreateFolder) { if (sysFolder->CreateRecursive() != VE_OK) ReleaseRefCountable( &sysFolder); } else { ReleaseRefCountable( &sysFolder); } } *outFolder = sysFolder; return MAKE_NATIVE_VERROR( winErr); }
VFolder::VFolder( const VFolder& inSource) { fPath = inSource.GetPath(); xbox_assert( fPath.IsFolder()); fFolder.Init( this); }
static void _ExplainTTRFormat_V1() { VString doc; char theTime[512] = {0}; time_t now = ::time( NULL); ::strftime( theTime, sizeof( theTime),"%Y-%m-%dT%H:%M:%S", localtime( &now)); doc = "Text (Tab-Tab-Return) format version "; doc.AppendLong(kTTR_FORMAT_VERSION); doc.AppendCString("\r\r"); // =============================================== doc += "--------------------------------------------------\r"; doc += "General\r"; doc += "--------------------------------------------------\r"; doc.AppendPrintf("Every entry is quoted by square brackets. For example: [%d] for \"FlushFromLanguage\".\r", eCLEntryKind_FlushFromLanguage); doc.AppendPrintf("First entry in the log is the \"start\" entry (%d), it gives the current date-time.\r", eCLEntryKind_Start); doc += "Then, every other entry is followed by [tab] ellapsed second since log started [tab] Task ID {and optionnaly: [tab] other infos...}\r\r"; doc += "For example, when the log starts, first line is something like:\r"; doc.AppendPrintf("[%d]\t%s\t10\r", eCLEntryKind_Start, theTime); doc += "Then you may have (FlushFromLanguage, executed 5 seconds since the log started, for task ID 10):\r"; doc.AppendPrintf("[%d]\t5\t10\r", eCLEntryKind_FlushFromLanguage); doc += "\rEntries may be quoted with start/end. In this case, the format is [entry num]s and [entry num]e."; doc += " Between both tags, several other entries may be logged, from the same task ID or from others.\r"; doc += "In all cases, the 'end' tag is formatted: [entry num]e [tab] ellapsed second since log started [tab] taskID [tab] count of milliseconds since [entry num]start\r"; doc += "For example, with the FlushFromLanguage kind launched from task ID 10, the log could be:\r"; doc.AppendPrintf("[%d]s\t123\t10\t(...other infos - see format)\r", eCLEntryKind_FlushFromLanguage); doc += ". . .\r. . .\r. . .\r"; doc.AppendPrintf("[%d]s\t126\t10\t(...other infos - see format)\r", eCLEntryKind_FlushFromLanguage); // =============================================== doc += "--------------------------------------------------\r"; doc += "List of all kinds of entry (name [tab] value)\r"; doc += "--------------------------------------------------\r"; doc.AppendPrintf("Unknown\t%d\r", eCLEntryKind_Unknown); doc.AppendPrintf("Start\t%d\r", eCLEntryKind_Start); doc.AppendPrintf("Stop\t%d\r", eCLEntryKind_Stop); doc.AppendPrintf("Comment\t%d\r", eCLEntryKind_Comment); doc.AppendPrintf("NeedsBytes\t%d\r", eCLEntryKind_NeedsBytes); doc.AppendPrintf("CallNeedsBytes\t%d\r", eCLEntryKind_CallNeedsBytes); doc.AppendPrintf("FlushFromLanguage\t%d\r", eCLEntryKind_FlushFromLanguage); doc.AppendPrintf("FlushFromMenuCommand\t%d\r", eCLEntryKind_FlushFromMenuCommand); doc.AppendPrintf("FlushFromScheduler\t%d\r", eCLEntryKind_FlushFromScheduler); doc.AppendPrintf("FlushFromBackup\t%d\r", eCLEntryKind_FlushFromBackup); doc.AppendPrintf("FlushFromNeedsBytes\t%d\r", eCLEntryKind_FlushFromNeedsBytes); doc.AppendPrintf("FlushFromRemote\t%d\r", eCLEntryKind_FlushFromRemote); doc.AppendPrintf("FlushFromUnknown\t%d\r", eCLEntryKind_FlushFromUnknown); doc.AppendPrintf("Flush\t%d\r", eCLEntryKind_Flush); doc.AppendPrintf("MemStats\t%d\r", eCLEntryKind_MemStats); doc.AppendCString("\r\r"); // =============================================== doc += "--------------------------------------------------\r"; doc += "Format and meaning of each kind\r"; doc += "--------------------------------------------------\r"; doc.AppendPrintf("[%d]\r", eCLEntryKind_Unknown); doc += "Unknown entry kind\r"; doc.AppendPrintf("[%d] [tab] ellapsed second since log started [tab] taskID\r\r", eCLEntryKind_Unknown); doc.AppendPrintf("[%d]\r", eCLEntryKind_Start); doc += "The log starts. Quoted (start/end) entry, with misc. infos between the start and the end.\r"; doc.AppendPrintf("[%d]s [tab] current time [tab] taskID [tab] version [cr]\r", eCLEntryKind_Start); doc.AppendPrintf("struct [tab] path to host database structure file [cr]\r"); doc.AppendPrintf("data [tab] path to host database data file [cr]\r"); doc.AppendPrintf("[%d]e\r\r", eCLEntryKind_Start); doc.AppendPrintf("[%d]\r", eCLEntryKind_Stop); doc += "The log ends\r"; doc.AppendPrintf("[%d] [tab] ellapsed second since log started [tab] taskID\r\r", eCLEntryKind_Stop); doc.AppendPrintf("[%d]\r", eCLEntryKind_Comment); doc += "A comment added by the developer. Comments are always quoted with start and end, a \\r is added at beginning and end.\r"; doc.AppendPrintf("[%d]start [tab] ellapsed second since log started [tab] taskID [cr] the comment [cr] [%d]end [tab] time [tab] taskID [tab] 0 (the milliseconds)\r\r", eCLEntryKind_Comment); doc.AppendPrintf("[%d]\r", eCLEntryKind_NeedsBytes); doc += "Any source asks memory to the cache manager\r"; doc.AppendPrintf("[%d] [tab] ellapsed second since log started [tab] taskID [tab] task name [tab] process 4D num [tab] needed bytes (very large int.)\r", eCLEntryKind_NeedsBytes); doc.AppendPrintf("Note: may be followed by [%d]\r\r", eCLEntryKind_MemStats); doc.AppendPrintf("[%d]\r", eCLEntryKind_CallNeedsBytes); doc += "Memory manager asks memory to the cache manager: not enough space in the cache to allocate memory. The cache manager will try to free unused objects, to flush, etc...\r"; doc.AppendPrintf("[%d] [tab] ellapsed second since log started [tab] taskID [tab] task name [tab] process 4D num [tab] needed bytes (very large int.)\r", eCLEntryKind_CallNeedsBytes); doc.AppendPrintf("Note: may be followed by [%d]\r\r", eCLEntryKind_MemStats); doc.AppendPrintf("[%d], [%d], [%d], [%d], [%d], [%d], [%d]\r", eCLEntryKind_FlushFromLanguage, eCLEntryKind_FlushFromMenuCommand, eCLEntryKind_FlushFromScheduler, eCLEntryKind_FlushFromBackup, eCLEntryKind_FlushFromNeedsBytes, eCLEntryKind_FlushFromRemote, eCLEntryKind_FlushFromUnknown); doc += "Action at the origin of a flush. All the 'FlushFrom...' share the same format.\r"; doc.AppendPrintf("[%d] [tab] ellapsed second since log started [tab] taskID [tab] task name [tab] process 4D num [tab] isWaitUntilDone (1 = yes, 0 = no, -1 = unknown) [tab] isEmptyCache (1 = yes, 0 = no, -1 = unknown)\r", eCLEntryKind_CallNeedsBytes); doc.AppendPrintf("Note: may be followed by [%d]\r", eCLEntryKind_MemStats); doc.AppendPrintf("Note: [%d] means a flush was requested from the remote, but we don't have the exact origin (does a client called FLUSH BUFFERS explicitely? ...)\r\r", eCLEntryKind_FlushFromRemote); doc.AppendPrintf("[%d]\r", eCLEntryKind_Flush); doc += "Flush (we are inside the Flush Manager)\r"; doc.AppendPrintf("[%d] [tab] ellapsed second since log started [tab] taskID\r", eCLEntryKind_Flush); doc.AppendPrintf("Note: may be followed by [%d]\r\r", eCLEntryKind_MemStats); doc.AppendPrintf("[%d]\r", eCLEntryKind_MemStats); doc += "The memory statistics. Level of stats is a bit field, to get specific stats, add the following values:\r"; doc.AppendPrintf("Mini stats (default value): %d\r", eCLDumpStats_Mini); doc.AppendPrintf("Objects: %d\r", eCLDumpStats_Objects); doc.AppendPrintf("Blocks: %d\r", eCLDumpStats_Blocks); doc.AppendPrintf("SmallBlocks: %d\r", eCLDumpStats_SmallBlocks); doc.AppendPrintf("BigBlocks: %d\r", eCLDumpStats_BigBlocks); doc.AppendPrintf("OtherBlocks: %d\r", eCLDumpStats_OtherBlocks); doc.AppendPrintf("All: %d\r", eCLDumpStats_All); doc.AppendPrintf("[%d] [tab] ellapsed second since log started [tab] taskID [tab] origin of the stats (a log entry number) [cr] the stats\r", eCLEntryKind_MemStats); doc += "the stats themselves are in xml:\r"; doc += "Main tag: <mem_stats level=\"stat level\" size=\"total amount of memory\" used=\"amount ofused memory\">\r"; doc += "Then come the details:\r"; doc += "<system phys=\"physical memory size\" free=\"free memory size\" app_used_phys=\"physical used by app\" used_virtual=\"virtual meory used\" />\r"; doc += "Allocations blocks: <alloc count=\"number of virtual allocations\" tot=\"total allocated\" />\r"; doc += "Then come the detailed stats, depending on the level. Note: infos are the same as the one found in GET CACHE STATISTIC."; doc += ", the xml uses some abbreviations to reduce a bit the size: bb = \"big blocks\", sb = \"small blocks\", ob = \"other blocks\"\r"; doc += "Example of log:\r"; doc += "<mem_stats level=\"1\" tid=\"13\" tname=\"P_1\" pnum=\"5\" size=\"10704570434977792\" used=\"2306663092733982407\">\r"; doc += "<system phys=\"2143993856\" free=\"1\" app_used_phys=\"2882306048\" used_virtual=\"0\"/>"; doc += "<alloc count=\"2\" tot=\"104857600\"/>"; doc += "<stats free=\"102365184\" nb_bb=\"165\" used_bb=\"163\" free_bb=\"2\" nb_pages=\"104\" nb_sb=\"4411\" used_sb=\"4401\" free_sb=\"10\" biggest_block=\"70124512\" biggest_free_block=\"70124512\" nb_obj=\"3852\"/>"; doc += "</mem_stats>\r\r"; VFolder *userDocsFolder = VFolder::RetainSystemFolder(eFK_UserDocuments, false); if(userDocsFolder != NULL) { VFile logDoc(*userDocsFolder, CVSTR("cache_log_doc_v1.txt")); VError err = VE_OK; if(logDoc.Exists()) err = logDoc.Delete(); err = logDoc.Create(); if(err == VE_OK) { VFileStream logDocDump(&logDoc); err = logDocDump.OpenWriting(); if(err == VE_OK) { logDocDump.PutText(doc); } if(err == VE_OK) err = logDocDump.CloseWriting(); } userDocsFolder->Release(); } }
VError VRIAServerSolution::_Open( VSolution* inDesignSolution, VRIAServerSolutionOpeningParameters *inOpeningParameters) { if (fState.opened) return VE_OK; VError err = VE_OK; if (!testAssert(fDesignSolution == NULL)) err = VE_UNKNOWN_ERROR; if (err == VE_OK && inDesignSolution == NULL) err = ThrowError( VE_RIA_INVALID_DESIGN_SOLUTION); if (err == VE_OK) { fDesignSolution = inDesignSolution; fDesignSolution->GetName( fName); CopyRefCountable( &fOpeningParameters, inOpeningParameters); if (fOpeningParameters == NULL) { fOpeningParameters = new VRIAServerSolutionOpeningParameters(); if (fOpeningParameters == NULL) err = ThrowError( VE_MEMORY_FULL); } if (err == VE_OK) fState.inMaintenance = fOpeningParameters->GetOpeningMode() == eSOM_FOR_MAINTENANCE; if (err == VE_OK && !fState.inMaintenance) { VSize nNameLength = fName. GetLength ( ) * 2 + 1; char* szchName = new char [ nNameLength ]; fName. ToCString ( szchName, nNameLength ); fprintf ( stdout, "Publishing solution \"%s\"\n", szchName ); delete [ ] szchName; } if (err == VE_OK && !fState.inMaintenance) { const VFolder * vfRoot = RetainFolder ( ); if ( vfRoot != 0 ) { VJSGlobalContext::SetSourcesRoot ( *vfRoot ); vfRoot-> Release ( ); VJSGlobalContext::AllowDebuggerLaunch ( ); } } fLoggerID = L"com.wakanda-software." + fName; if (err == VE_OK && !fState.inMaintenance) { // Create a messages logger VFolder *logFolder = RetainLogFolder( true); if (logFolder != NULL) { fLogger = new VLog4jMsgFileLogger( *logFolder, fName + L"_log"); if (fLogger == NULL) { err = ThrowError( VE_MEMORY_FULL); } else { VRIAServerApplication::Get()->SetLogger( fLogger); fLogger->Start(); } logFolder->Release(); } else { err = ThrowError( VE_RIA_LOG_FOLDER_NOT_FOUND); } } StUseLogger logger; if (err == VE_OK && !fState.inMaintenance) { // Create a log file reader fLogReader = new VLog4jMsgFileReader(); if (fLogReader == NULL) err = ThrowError( VE_MEMORY_FULL); else fLogger->AttachReader( fLogReader); } if (err == VE_OK || fState.inMaintenance) { StErrorContextInstaller errContext; VMicrosecondsCounter usCounter; usCounter.Start(); logger.Log( fLoggerID, eL4JML_Information, L"Opening the solution"); if (err == VE_OK && !fState.inMaintenance) { fJSRuntimeDelegate = new VRIAServerSolutionJSRuntimeDelegate( this); if (fJSRuntimeDelegate == NULL) err = ThrowError( VE_MEMORY_FULL); } if (err == VE_OK && !fState.inMaintenance) { fJSContextPool = VRIAServerApplication::Get()->GetJSContextMgr()->CreateJSContextPool( err, this); } if (err == VE_OK || fState.inMaintenance) { // Load all available settings files err = _LoadFileSettings(); if (err != VE_OK) err = ThrowError( VE_RIA_CANNOT_LOAD_SETTINGS_FILES); } if (err == VE_OK || fState.inMaintenance) { // Load the database settings err = _LoadDatabaseSettings(); if (err != VE_OK) err = ThrowError( VE_RIA_CANNOT_LOAD_DATABASE_SETTINGS); } if (err == VE_OK || fState.inMaintenance) { // Load users and groups directory fUAGDirectory = _OpenUAGDirectory( err); if (err != VE_OK) err = ThrowError( VE_RIA_CANNOT_LOAD_UAG_DIRECTORY); } if (err == VE_OK || fState.inMaintenance) { // Build the ServerAdmin project file path VFilePath serverAdminProjectPath; VFolder *folder = VRIAServerApplication::Get()->RetainApplicationResourcesFolder(); if (folder != NULL) { folder->GetPath( serverAdminProjectPath); serverAdminProjectPath.ToSubFolder( L"Default Solution"); serverAdminProjectPath.ToSubFolder( L"Admin"); // sc 18/02/2011 "ServerAdmin" become "Admin" serverAdminProjectPath.SetFileName( L"ServerAdmin", false); serverAdminProjectPath.SetExtension( RIAFileKind::kProjectFileExtension); } ReleaseRefCountable( &folder); // Opening the applications if (fApplicationsMutex.Lock()) { // Note: the ServerAdmin project may be the project of the default solution // or the ServerAdmin project added to a solution which has none admin project. bool hasAdmin = false; VProject *serverAdminProject = fDesignSolution->GetProjectFromFilePathOfProjectFile( serverAdminProjectPath); bool ignoreProjectOpeningErrors = !fSettings.GetStopIfProjectFails(); fGarbageCollect = fSettings.GetGarbageCollect(); VectorOfProjects designProjects; fDesignSolution->GetVectorOfProjects( designProjects); for (VectorOfProjects::iterator iter = designProjects.begin() ; iter != designProjects.end() && (err == VE_OK || fState.inMaintenance) ; ++iter) { if (*iter != NULL) { VRIAServerProject *application = NULL; // Create opening parameters VRIAServerProjectOpeningParameters *projectOpeningParams = new VRIAServerProjectOpeningParameters(); if (projectOpeningParams != NULL) { projectOpeningParams->SetOpeningMode( fState.inMaintenance ? ePOM_FOR_MAINTENANCE : ePOM_FOR_RUNNING); sLONG defaultAdminPort = 0; if (*iter == serverAdminProject && fOpeningParameters->GetCustomAdministratorHttpPort( defaultAdminPort)) projectOpeningParams->SetCustomHttpPort( defaultAdminPort); // for Default solution, pass the WebAdmin opening parameters application = VRIAServerProject::OpenProject( err, this, *iter, projectOpeningParams); if ((application != NULL) && (err == VE_OK || fState.inMaintenance)) { VUUID uuid; xbox_assert(application->GetUUID( uuid)); fApplicationsCollection.push_back( VRefPtr<VRIAServerProject>(application)); fApplicationsMap[uuid] = VRefPtr<VRIAServerProject>(application); hasAdmin |= application->IsAdministrator(); if (!fState.inMaintenance) { VString vstrHostName; VString vstrIP; sLONG nPort = 0; VString vstrPattern; VString vstrPublishName; VError vErrorS = application-> GetPublicationSettings ( vstrHostName, vstrIP, nPort, vstrPattern, vstrPublishName ); xbox_assert ( vErrorS == VE_OK ); vstrPublishName. Clear ( ); application-> GetName ( vstrPublishName ); VString vstrMessage; vstrMessage. AppendCString ( "\tProject \"" ); vstrMessage. AppendString ( vstrPublishName ); vstrMessage. AppendCString ( "\" published at " ); vstrMessage. AppendString ( vstrIP ); vstrMessage. AppendCString ( " on port " ); vstrMessage. AppendLong ( nPort ); vstrMessage. AppendCString ( "\n" ); VSize nNameLength = vstrMessage. GetLength ( ) * 2 + 1; char* szchName = new char [ nNameLength ]; vstrMessage. ToCString ( szchName, nNameLength ); fprintf ( stdout, szchName ); delete [ ] szchName; } } ReleaseRefCountable( &projectOpeningParams); } else { err = ThrowError( VE_MEMORY_FULL); } if (err != VE_OK) { VString name; (*iter)->GetName( name); VErrorBase *errBase = CreateErrorBase( VE_RIA_CANNOT_OPEN_PROJECT, &name, NULL); logger.LogMessageFromErrorBase( fLoggerID, errBase); ReleaseRefCountable( &errBase); if (!fState.inMaintenance) { if (application != NULL) application->Close(); if (ignoreProjectOpeningErrors) err = VE_OK; else err = VE_RIA_CANNOT_OPEN_PROJECT; } } ReleaseRefCountable( &application); } } if (!hasAdmin && !fState.inMaintenance && (err == VE_OK)) { VFile file( serverAdminProjectPath); if (file.Exists()) { VURL url( serverAdminProjectPath); fDesignSolution->AddExistingProject( url, false); VProject *designProject = fDesignSolution->GetProjectFromFilePathOfProjectFile( serverAdminProjectPath); if (designProject != NULL) { VRIAServerProject *application = NULL; // Create opening parameters VRIAServerProjectOpeningParameters *projectOpeningParams = new VRIAServerProjectOpeningParameters(); if (projectOpeningParams != NULL) { projectOpeningParams->SetOpeningMode( ePOM_FOR_RUNNING); sLONG defaultAdminPort = 0; if (fOpeningParameters->GetCustomAdministratorHttpPort( defaultAdminPort)) projectOpeningParams->SetCustomHttpPort( defaultAdminPort); application = VRIAServerProject::OpenProject( err, this, designProject, projectOpeningParams); if (application != NULL && err == VE_OK) { VUUID uuid; xbox_assert(application->GetUUID( uuid)); fApplicationsCollection.push_back( VRefPtr<VRIAServerProject>(application)); fApplicationsMap[uuid] = VRefPtr<VRIAServerProject>(application); } ReleaseRefCountable( &projectOpeningParams); } else { err = ThrowError( VE_MEMORY_FULL); } if (err != VE_OK) { VString name; designProject->GetName( name); VErrorBase *errBase = CreateErrorBase( VE_RIA_CANNOT_OPEN_PROJECT, &name, NULL); logger.LogMessageFromErrorBase( fLoggerID, errBase); ReleaseRefCountable( &errBase); if (application != NULL) application->Close(); if (ignoreProjectOpeningErrors) err = VE_OK; else err = VE_RIA_CANNOT_OPEN_PROJECT; } ReleaseRefCountable( &application); } } } fApplicationsMutex.Unlock(); } } logger.LogMessagesFromErrorContext( fLoggerID, errContext.GetContext()); if (err == VE_OK) { VString logMsg; logMsg.Printf( "Solution opened (duration: %i ms)", usCounter.Stop()/1000); logger.Log( fLoggerID, eL4JML_Information, logMsg); } } } fState.opened = true; return err; }