Ejemplo n.º 1
0
void VJSRequireClass::_Initialize (const VJSParms_initialize &inParms, void *)
{
	XBOX::VJSObject	thisObject(inParms.GetObject());
	XBOX::VJSArray	arrayObject(inParms.GetContext());
	XBOX::VFolder	*folder = XBOX::VFolder::RetainSystemFolder(eFK_Executable, false);

	xbox_assert(folder != NULL);	
	
#if VERSIONMAC
	
	XBOX::VFolder	*parentFolder = folder->RetainParentFolder();
	
	XBOX::VFilePath	path(parentFolder->GetPath(), "Modules/", FPS_POSIX);
	
	XBOX::ReleaseRefCountable<XBOX::VFolder>(&parentFolder);
	
#else
	
	XBOX::VFilePath	path(folder->GetPath(), "Modules/", FPS_POSIX);
	
#endif	

	XBOX::ReleaseRefCountable<XBOX::VFolder>(&folder);

	XBOX::VString	defaultPath;

	path.GetPosixPath(defaultPath);

	thisObject.SetProperty("paths", arrayObject, JS4D::PropertyAttributeDontDelete);
	arrayObject.PushString(defaultPath);
}
/* private */
void VVirtualFolder::_NormalizeFolder()
{
	assert (NULL != fFolder);

	if (!fFolder->Exists())
		fFolder->CreateRecursive();

	if (fFolder->Exists())
	{
		XBOX::VFilePath folderPath (fFolder->GetPath());
		XBOX::VFilePath indexPath;

		indexPath = folderPath.ToSubFile (fIndexFileName);

		if (indexPath.IsFile())
		{
			XBOX::VFile indexFile (indexPath);

			if (!indexFile.Exists())
			{
				XBOX::VFolder *componentFolder = VHTTPServer::RetainComponentFolder (kBF_RESOURCES_FOLDER);

				if (NULL != componentFolder)
				{
					XBOX::VFilePath		defaultIndexPath = componentFolder->GetPath();
					XBOX::DialectCode	dialectCode = XBOX::VIntlMgr::GetDefaultMgr()->GetCurrentDialectCode();
					XBOX::VString		languageCode;
					XBOX::VString		fileName;

					XBOX::VIntlMgr::GetDefaultMgr()->GetISO6391LanguageCode (dialectCode, languageCode);

					fileName.AppendCString ("index_");
					fileName.AppendString (languageCode);
					fileName.AppendCString (".html");

					defaultIndexPath.ToSubFolder (CVSTR ("Default Page")).ToSubFile (fileName);

					if (defaultIndexPath.IsFile())
					{
						XBOX::VFile defaultIndexFile (defaultIndexPath);

						if (defaultIndexFile.Exists())
							indexFile.CopyFrom (defaultIndexFile);
					}

					XBOX::QuickReleaseRefCountable (componentFolder);
				}
			}
		}
	}
}
void VHTTPServerLog::_GetLogFilePath (XBOX::VFilePath& outFilepath)
{
	XBOX::VFilePath logFolderPath (fSettings.GetLogPath());

	if (logFolderPath.IsValid() && logFolderPath.IsFolder())
	{
		XBOX::VFolder folder (fSettings.GetLogPath());

		if (!folder.Exists())
			folder.CreateRecursive();
	}

	outFilepath.FromFilePath (fSettings.GetLogPath());
	outFilepath.SetFileName (fSettings.GetLogFileName());
}
Ejemplo n.º 4
0
void VJSModuleState::_GetRequireFunctionURL (XBOX::VString *outURLString)
{
	XBOX::VFolder	*folder = XBOX::VFolder::RetainSystemFolder(eFK_Executable, false);

	xbox_assert(folder != NULL);	
	
#if VERSIONMAC
	
	XBOX::VFolder	*parentFolder = folder->RetainParentFolder();
	
	XBOX::VFilePath	path(parentFolder->GetPath(), "Resources/Web Components/walib/WAF/Core/Native/requireFunction.js", FPS_POSIX);
	XBOX::VFile		file(path);

	if (!file.Exists()) {

		path.FromRelativePath(parentFolder->GetPath(), "walib/WAF/Core/Native/requireFunction.js", FPS_POSIX);

	}
	
	XBOX::ReleaseRefCountable<XBOX::VFolder>(&parentFolder);
	
#else
	
	XBOX::VFilePath	path(folder->GetPath(), "Resources/Web Components/walib/WAF/Core/Native/requireFunction.js", FPS_POSIX);
	XBOX::VFile		file(path);

	if (!file.Exists()) 

		path.FromRelativePath(folder->GetPath(), "walib/WAF/Core/Native/requireFunction.js", FPS_POSIX);
	
#endif	
	
	path.GetPosixPath(*outURLString);

	XBOX::ReleaseRefCountable<XBOX::VFolder>(&folder);
}
XBOX::VError VHTTPServerLog::_RotateFile()
{
	XBOX::VError	error = XBOX::VE_OK;
	XBOX::VFilePath	logFilePath;
	XBOX::VTime		curTime;

	curTime.FromSystemTime();

	_GetLogFilePath (logFilePath);

	if (fLogFileAccessLock.Lock())
	{
		if (NULL == fLogFile)
			fLogFile = new XBOX::VFile (logFilePath);

		if (fLogFile->Exists())
		{
			// the backup fileName will look like "HTTPServer_DAAAAMMJJT00000000.waLog" => "HTTPServer_D20100122T113307.waLog"
			// I used this format to have the files sorted by time thanks to their name

			XBOX::VString	newFileName;
			XBOX::VString	dateTimeString;

			GetFormatedDateTimeString (curTime, dateTimeString);

			fLogFile->GetNameWithoutExtension (newFileName);
			newFileName.AppendUniChar (CHAR_LOW_LINE);
			newFileName.AppendString (dateTimeString);
			newFileName.AppendUniChar (CHAR_FULL_STOP);
			newFileName.AppendString (fSettings.GetLogFileNameExtension());

			if (fSettings.GetArchivesFolderName().IsEmpty())
			{
				error = fLogFile->Rename (newFileName);
			}
			else
			{
				XBOX::VFilePath	destinationFilePath;

				fLogFile->GetPath (destinationFilePath);
				destinationFilePath.ToParent().ToSubFolder (fSettings.GetArchivesFolderName());

				if (destinationFilePath.IsFolder())
				{
					XBOX::VFolder *	destinationFolder = new XBOX::VFolder (destinationFilePath);
					if (NULL != destinationFolder)
					{
						if (!destinationFolder->Exists())
							error = destinationFolder->CreateRecursive();
						XBOX::ReleaseRefCountable (&destinationFolder);

						if (XBOX::VE_OK == error)
						{
							destinationFilePath.SetFileName (newFileName);

							error = fLogFile->Move (destinationFilePath, NULL, XBOX::FCP_Overwrite);
						}
					}
					else
					{
						error = XBOX::VE_MEMORY_FULL;
					}
				}
			}

			XBOX::ReleaseRefCountable (&fLogFile);
		}

		//Creating the log file
		if ((XBOX::VE_OK == error) && (NULL == fLogFile))
		{
			fLogFile = new XBOX::VFile (logFilePath);
			if (NULL != fLogFile)
			{
				error = fLogFile->Create();

				// Set correct dates & times (used later to determine the next backup time)
				if (XBOX::VE_OK == error)
					error = fLogFile->SetTimeAttributes (&curTime, &curTime, &curTime);
				fLogFileSize = 0;
				
				fLastFileRotationTime.FromTime (curTime);
				_CalculateNextFileRotationTime();
			}
			else
			{
				error = VE_CANNOT_CREATE_LOG_FILE;
			}
		}
		else
		{
			error = VE_CANNOT_OPEN_LOG_FILE;
		}

		fNeedSplit = false;
		fLogFileAccessLock.Unlock();
	}

	return error;
}