Exemplo n.º 1
2
int cp_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_IOMAN *pIoman = pEnv->pIoman;
	FF_FILE *fSource, *fDest;
	FF_ERROR Error;

	FF_T_INT8 path[FF_MAX_PATH];
	FF_T_UINT8 copybuf[COPY_BUFFER_SIZE];

	FF_T_SINT32	BytesRead;

	//LARGE_INTEGER ticksPerSecond;
	//LARGE_INTEGER start_ticks, end_ticks, cputime;
	float transferRate = 0;

	//QueryPerformanceFrequency(&ticksPerSecond);
	
	if(argc == 3) {
		if(strstr(argv[1], "*") || strstr(argv[2], "*")) {
			return wildcopy(argc, argv, pEnv);
		}
		ProcessPath(path, argv[1], pEnv);

		fSource = FF_Open(pIoman, path, FF_MODE_READ, &Error);

		if(fSource) {
			ProcessPath(path, argv[2], pEnv);

			fDest = FF_Open(pIoman, path, FF_GetModeBits("w"), &Error);
			if(fDest) {
				// Do the copy
				//QueryPerformanceCounter(&start_ticks);   
				//QueryPerformanceCounter(&end_ticks);   
				do{
					BytesRead = FF_Read(fSource, COPY_BUFFER_SIZE, 1, (FF_T_UINT8 *)copybuf);
					FF_Write(fDest, BytesRead, 1, (FF_T_UINT8 *) copybuf);
					//QueryPerformanceCounter(&end_ticks); 
					//cputime.QuadPart = end_ticks.QuadPart - start_ticks.QuadPart;
					//time = ((float)cputime.QuadPart/(float)ticksPerSecond.QuadPart);
					//transferRate = (fSource->FilePointer / time) / 1024;
					//cons_printf("%f% - %10ld Bytes Copied, %f Kb/S\r", ((float)((float)fSource->FilePointer/(float)fSource->Filesize) * 100), fSource->FilePointer, transferRate);
				}while(BytesRead > 0);
				//cons_printf("%f% - %10ld Bytes Copied, %f Kb/S\n", ((float)((float)fSource->FilePointer/(float)fSource->Filesize) * 100), fSource->FilePointer, transferRate);		

				FF_Close(fSource);
				FF_Close(fDest);
			} else {
				FF_Close(fSource);
				cons_printf("Could not open destination file - %s\n", FF_GetErrMessage(Error));
			}

		} else {
			cons_printf("Could not open source file - %s\n", FF_GetErrMessage(Error));
		}
		
	} else {
		cons_printf("Usage: %s [source file] [destination file]\n", argv[0]);
	}
	return 0;
}
Exemplo n.º 2
2
int mkfile_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	
	FF_FILE *f;
	FF_T_UINT32	Bytes;
	FF_T_UINT32	BytesWritten = 0;
	FF_T_UINT32 ElementSize = 0, Elements = 0, Multiplier = 0;
	FF_T_UINT8 IntBuffer[4096*4];	// 16Kb of Integers!
	FF_T_UINT32	i = 0, x;
	FF_T_INT8	path[FF_MAX_PATH];
	FF_ERROR	Error;

	FF_T_UINT64 TicksPerSecond, TicksStart, TicksEnd, Ticks;

	float transferRate = 0.0, time;

	TicksPerSecond = FFTerm_GetTickRate(pEnv->pConsole);

	if(argc == 5) {
		sscanf(argv[1], "%lu", &ElementSize);
		/*if(!ElementSize) {
			printf("Invalid Element Size!\n");
			return 0;
			}*/

		sscanf(argv[2], "%lu", &Elements);
		/*if(!Elements) {
			printf("Invalid Number of Elements\n");
			return 0;
			}*/

		sscanf(argv[3], "%lu", &Multiplier);
		/*if(!Multiplier) {
			printf("Invalid Multiplier\n");
			return 0;
			}*/

		Bytes = ElementSize * Elements * Multiplier;

		printf("Creating file of size %lu Bytes (%0.2f MB) (%0.3f GB)\n", Bytes, (float)((float)Bytes / 1048576.0), (float)(((float)Bytes / 1048576.0)/1024.0));
		
		ProcessPath(path, argv[4], pEnv);

		f = FF_Open(pEnv->pIoman, path, FF_GetModeBits("wb"), &Error);

		if(f) {
			while(Bytes) {
				
				for(x = 0; x < 4096*4; x++) {
					IntBuffer[x] = (FF_T_UINT8)i++;
				}
				
				TicksStart = FFTerm_GetTicks(pEnv->pConsole);
				if(Bytes >= (4096 * 4)) {
					BytesWritten += 4096 * 4;
					Bytes -= FF_Write(f, 1, 4096 * 4, (FF_T_UINT8 *) IntBuffer);
				} else {
					BytesWritten += Bytes;
					Bytes -= FF_Write(f, 1, Bytes, (FF_T_UINT8 *) IntBuffer);
				}
				TicksEnd = FFTerm_GetTicks(pEnv->pConsole);
				
				Ticks += (TicksEnd - TicksStart);
				time = ((float)Ticks/(float)TicksPerSecond);
				transferRate = (BytesWritten / time) / 1024;

				printf("Written %0.2f MB (%7.2f KB/s)\r", (float) ((float)BytesWritten / 1048576.0), transferRate);
			}

			printf("Written %0.2f MB (%7.2f KB/s)\n", (float) ((float)BytesWritten / 1048576.0), transferRate);

			FF_Close(f);
		} else {
			printf("Error opening file: %s\n", FF_GetErrMessage(Error));
		}
		
	} else {
		printf("Generates a File filled with 32-bit integers.\n\n");
		printf("Usage: %s [Element Size] [Elements] [Multiplier] [filename]\n\n", argv[0]);
		printf("E.g. a 1Mb File, \tFullFAT\\>%s 1024\t 1024\t 1\t 1m.dat\n", argv[0]);
		printf("E.g. a 2Mb File, \tFullFAT\\>%s 1024\t 1024\t 2\t 2m.dat\n", argv[0]);
		printf("E.g. a 10Mb File, \tFullFAT\\>%s 1024\t 1024\t 10\t 10m.dat\n", argv[0]);
		printf("E.g. a 100Mb File, \tFullFAT\\>%s 1024\t 1024\t 100\t 100m.dat\n\n", argv[0]);
	}

	return 0;
}
Exemplo n.º 3
0
/**
 *	@public
 *	@brief	Changes the Current Working Directory
 *
 *	To change the directory, we simply check the provided path, if it exists,
 *	then we change the environment's working directory to that path.
 *
 **/
int cd_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_IOMAN *pIoman = pEnv->pIoman;
	FF_T_INT8	path[FF_MAX_PATH];

	int i;

	if(argc == 2) {
		ProcessPath(path, argv[1], pEnv);	// Make path absolute if relative.

		ExpandPath(path);	// Remove any relativity from the path (../ or ..\).
		
		if(FF_FindDir(pIoman, path, (FF_T_UINT16) strlen(path))) {	// Check if path is valid.
			i = strlen(path) - 1;	// Path found, change the directory.

			if(i) {
				if(path[i] == '\\' || path[i] == '/') {
					path[i] = '\0';
				}
			}
			strcpy(pEnv->WorkingDir, path);
			//sprintf(pEnv->WorkingDir, path);
		} else {
			cons_printf("Path \"%s\" not found.\n", path);
		}
	} else {
		cons_printf("Usage: %s [path]\n", argv[0]);
	}
	return 0;
}
Exemplo n.º 4
0
void CPDF_RenderStatus::ProcessObjectNoClip(CPDF_PageObject* pObj,
                                            const CFX_Matrix* pObj2Device) {
#if defined _SKIA_SUPPORT_
  DebugVerifyDeviceIsPreMultiplied();
#endif
  FX_BOOL bRet = FALSE;
  switch (pObj->GetType()) {
    case CPDF_PageObject::TEXT:
      bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr);
      break;
    case CPDF_PageObject::PATH:
      bRet = ProcessPath(pObj->AsPath(), pObj2Device);
      break;
    case CPDF_PageObject::IMAGE:
      bRet = ProcessImage(pObj->AsImage(), pObj2Device);
      break;
    case CPDF_PageObject::SHADING:
      ProcessShading(pObj->AsShading(), pObj2Device);
      return;
    case CPDF_PageObject::FORM:
      bRet = ProcessForm(pObj->AsForm(), pObj2Device);
      break;
  }
  if (!bRet)
    DrawObjWithBackground(pObj, pObj2Device);
#if defined _SKIA_SUPPORT_
  DebugVerifyDeviceIsPreMultiplied();
#endif
}
Exemplo n.º 5
0
void CPDF_RenderStatus::DrawTextPathWithPattern(
    const CPDF_TextObject* textobj,
    const CFX_AffineMatrix* pObj2Device,
    CPDF_Font* pFont,
    FX_FLOAT font_size,
    const CFX_AffineMatrix* pTextMatrix,
    FX_BOOL bFill,
    FX_BOOL bStroke) {
  if (!bStroke) {
    CPDF_PathObject path;
    CPDF_TextObject* pCopy = new CPDF_TextObject;
    pCopy->Copy(textobj);
    path.m_bStroke = FALSE;
    path.m_FillType = FXFILL_WINDING;
    path.m_ClipPath.AppendTexts(&pCopy, 1);
    path.m_ColorState = textobj->m_ColorState;
    path.m_Path.New()->AppendRect(textobj->m_Left, textobj->m_Bottom,
                                  textobj->m_Right, textobj->m_Top);
    path.m_Left = textobj->m_Left;
    path.m_Bottom = textobj->m_Bottom;
    path.m_Right = textobj->m_Right;
    path.m_Top = textobj->m_Top;
    RenderSingleObject(&path, pObj2Device);
    return;
  }
  CFX_FontCache* pCache;
  if (pFont->m_pDocument) {
    pCache = pFont->m_pDocument->GetRenderData()->GetFontCache();
  } else {
    pCache = CFX_GEModule::Get()->GetFontCache();
  }
  CFX_FaceCache* pFaceCache = pCache->GetCachedFace(&pFont->m_Font);
  FX_FONTCACHE_DEFINE(pCache, &pFont->m_Font);
  CPDF_CharPosList CharPosList;
  CharPosList.Load(textobj->m_nChars, textobj->m_pCharCodes,
                   textobj->m_pCharPos, pFont, font_size);
  for (FX_DWORD i = 0; i < CharPosList.m_nChars; i++) {
    FXTEXT_CHARPOS& charpos = CharPosList.m_pCharPos[i];
    const CFX_PathData* pPath = pFaceCache->LoadGlyphPath(
        &pFont->m_Font, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
    if (pPath == NULL) {
      continue;
    }
    CPDF_PathObject path;
    path.m_GraphState = textobj->m_GraphState;
    path.m_ColorState = textobj->m_ColorState;
    CFX_AffineMatrix matrix;
    if (charpos.m_bGlyphAdjust)
      matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
                 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
    matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX,
                  charpos.m_OriginY);
    path.m_Path.New()->Append(pPath, &matrix);
    path.m_Matrix = *pTextMatrix;
    path.m_bStroke = bStroke;
    path.m_FillType = bFill ? FXFILL_WINDING : 0;
    path.CalcBoundingBox();
    ProcessPath(&path, pObj2Device);
  }
}
Exemplo n.º 6
0
void CPDF_RenderStatus::ProcessObjectNoClip(
    const CPDF_PageObject* pObj,
    const CFX_AffineMatrix* pObj2Device) {
  FX_BOOL bRet = FALSE;
  switch (pObj->m_Type) {
    case PDFPAGE_TEXT:
      bRet = ProcessText((CPDF_TextObject*)pObj, pObj2Device, NULL);
      break;
    case PDFPAGE_PATH:
      bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device);
      break;
    case PDFPAGE_IMAGE:
      bRet = ProcessImage((CPDF_ImageObject*)pObj, pObj2Device);
      break;
    case PDFPAGE_SHADING:
      bRet = ProcessShading((CPDF_ShadingObject*)pObj, pObj2Device);
      break;
    case PDFPAGE_FORM:
      bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device);
      break;
  }
  if (!bRet) {
    DrawObjWithBackground(pObj, pObj2Device);
  }
}
Exemplo n.º 7
0
int more_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_FILE		*f;
	FF_ERROR	Error;
	FF_T_SINT32	c;
	FF_T_INT8	path[FF_MAX_PATH];

	if(argc == 2) {

		ProcessPath(path, argv[1], pEnv);

		f = FF_Open(pEnv->pIoman, path, FF_MODE_READ, &Error);
		if(f) {
			printf("//---------- START OF FILE\n");
			while(!FF_isEOF(f)) {
				c = FF_GetC(f);
				if(c >= 0) {
					printf("%c", (FF_T_INT8) c);
				} else {
					printf("Error while reading file: %s\n", FF_GetErrMessage(c));
					FF_Close(f);
					return -3;
				}
			}
			printf("\n//---------- END OF FILE\n");

			FF_Close(f);
		} else {
			printf("Could not open file: %s\n", FF_GetErrMessage(Error));
			return -2;
		}
	} else {
		printf("Usage: %s [filename]\n", argv[0]);
	}
	return 0;
}
Exemplo n.º 8
0
int createthread_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	THREAD hThread = (THREAD) malloc(sizeof(struct _IO_THREAD));
	THREAD hThreadList = g_ThreadList;
	FF_T_INT8	Path[FF_MAX_PATH];
	FF_ERROR Error;
	
	if(argc == 2) {
		
		if(hThread) {	
			hThread->isDead = FF_FALSE;
			hThread->pNext = NULL;
			hThread->nThreadBytes = 0;
			hThread->nThreadNum = 0;
			hThread->tKill = FF_FALSE;

			ProcessPath(Path, argv[1], pEnv);

			hThread->pFile = FF_Open(pEnv->pIoman, Path, FF_GetModeBits("w+"), &Error);

			if(!hThread->pFile) {
				free(hThread);
				printf("Error opening file: %s\n", FF_GetErrMessage(Error));
				return 0;
			}

			hThread->hThread = CreateThread(0, 0, IOTestThread, hThread, 0, &hThread->dwThreadID);
			
			if(hThread->hThread) {
				if(!hThreadList) {
					g_ThreadList = hThread;
				} else {
					hThread->nThreadNum = 1;
					while(hThreadList->pNext) {
						hThreadList = hThreadList->pNext;
						hThread->nThreadNum += 1;
					}

					hThreadList->pNext = hThread;
				}

			} else {
				FF_Close(hThread->pFile);
				free(hThread);
				printf("Error creating thread!\n");
			}
		} else {
			printf("Not enough memory!\n");
		}

	} else {
		printf("Usage: %s [filename]\n", argv[0]);
	}

	return 0;

}
Exemplo n.º 9
0
int move_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_T_INT8	src[FF_MAX_PATH];
	FF_T_INT8	dest[FF_MAX_PATH];
	FF_ERROR	Error;

	if(argc == 3) {
		ProcessPath(src, argv[1], pEnv);
		ProcessPath(dest, argv[2], pEnv);

		Error = FF_Move(pEnv->pIoman, src, dest);
		if(Error) {
			cons_printf("Error: %s\n", FF_GetErrMessage(Error));
		}
	} else {
		cons_printf("Usage: %s [Source Path] [Destination Path]\n", argv[0]);
	}

	return 0;
}
Exemplo n.º 10
0
    int StartupMain()
    {
        // Create a shortcut to this in Startup so
        // we run whenever the computer turns on.
        std::string here = ProcessPath();
        std::string there = ShortcutPath();

        std::ofstream out(there);
        out << "[InternetShortcut]" << std::endl;
        out << "URL=file:///" << replace(here, std::string("\\"), std::string("/"));
        
        return 0;
    }
Exemplo n.º 11
0
/*
	A View command to type out the contents of a file using FullFAT.
*/
int rm_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	
	FF_ERROR	Error;
	FF_DIRENT	mydir;	// Used to detect if its a file or folder.
	FF_T_INT8	path[FF_MAX_PATH];
	FF_T_INT8	realpath[FF_MAX_PATH];
	FF_T_INT8	*pName;
	int i;

	if(argc == 2) {

		ProcessPath(path, argv[1], pEnv);

		for(i = strlen(path); ; i--) {
			if(path[i] == '\\' || path[i] == '/') {
				pName = &path[i + 1];
				break;
			}
		}

		memcpy(realpath, path, i + 1);
		realpath[i+1] = '\0';

		Error = FF_FindFirst(pEnv->pIoman, &mydir, realpath);

		while(!FF_strmatch(mydir.FileName, pName, 0)) {
			Error = FF_FindNext(pEnv->pIoman, &mydir);
			if(Error) {	// File
				cons_printf("File or Folder not found!\n");
				return 0;
			}
		}

		if(mydir.Attrib & FF_FAT_ATTR_DIR) {
			Error = FF_RmDir(pEnv->pIoman, path);
		} else {
			Error = FF_RmFile(pEnv->pIoman, path);
		}

		if(Error) {
			cons_printf("Could not remove file or folder: %s\n", FF_GetErrMessage(Error));
		}


	} else {
		cons_printf("Usage: %s [filename]\n", argv[0]);
	}
	return 0;
}
Exemplo n.º 12
0
/**
 *	@brief	A simple command for making dirs.
 **/
int mkdir_cmd(int argc, char **argv, FF_ENVIRONMENT *pEv) {
	
	FF_T_INT8	path[FF_MAX_PATH];
	FF_ERROR	Error;

	if(argc == 2) {
		ProcessPath(path, argv[1], pEv);
		Error = FF_MkDir(pEv->pIoman, path);
		if(Error) {
			cons_printf("Could not mkdir - %s\n", FF_GetErrMessage(Error));
		}
	} else {
		cons_printf("Usage: %s [path]\n", argv[0]);
	}
	return 0;
}
Exemplo n.º 13
0
void AStar::FindPath()
{
	// Process the path bit by bit to avoid lag
	if(m_initialized){
		for(int i = 0; i < 50; i++)
		{
			if(m_openList.empty() || PathComplete())
			{
				break;
			}
			else
			{
				ProcessPath();
			}
		}
	}
}
Exemplo n.º 14
0
FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(
    const CPDF_PageObject* pObj,
    const CFX_AffineMatrix* pObj2Device) {
  FX_BOOL bRet = FALSE;
  switch (pObj->m_Type) {
    case PDFPAGE_PATH:
      bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device);
      break;
    case PDFPAGE_IMAGE:
      bRet = ProcessImage((CPDF_ImageObject*)pObj, pObj2Device);
      break;
    case PDFPAGE_FORM:
      bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device);
      break;
  }
  return bRet;
}
Exemplo n.º 15
0
FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj,
                                            const CFX_Matrix* pObj2Device) {
  FX_BOOL bRet = FALSE;
  switch (pObj->GetType()) {
    case CPDF_PageObject::PATH:
      bRet = ProcessPath(pObj->AsPath(), pObj2Device);
      break;
    case CPDF_PageObject::IMAGE:
      bRet = ProcessImage(pObj->AsImage(), pObj2Device);
      break;
    case CPDF_PageObject::FORM:
      bRet = ProcessForm(pObj->AsForm(), pObj2Device);
      break;
    default:
      break;
  }
  return bRet;
}
Exemplo n.º 16
0
/**
 *	@public
 *	@brief	MD5 Data Hashing function.
 *
 *	Generates and displays an MD5 hash of a file. This is really useful when
 *	verify files for their integrity. We used MD5 extensively while stabilising
 *	the read and write functionality of FullFAT.
 *
 **/
int md5_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_IOMAN	*pIoman = pEnv->pIoman;
	FF_T_INT8	path[FF_MAX_PATH];
	FF_T_UINT8	readBuf[8192];
	FF_FILE		*fSource;
	FF_ERROR	Error;

	int			len;
	md5_state_t state;
	md5_byte_t	digest[16];
	int			di;
	
	if(argc == 2) {
		
		ProcessPath(path, argv[1], pEnv);

		fSource = FF_Open(pIoman, path, FF_MODE_READ, &Error);

		if(fSource) {
			md5_init(&state);
			do {
				len = FF_Read(fSource, 1, 8192, readBuf);
				md5_append(&state, (const md5_byte_t *)readBuf, len);
			} while(len);
			
			md5_finish(&state, digest);

			for (di = 0; di < 16; ++di)
				cons_printf("%02x", digest[di]);

			cons_printf ("\n");

			FF_Close(fSource);
		} else {
			cons_printf("Could not open file - %s\n", FF_GetErrMessage(Error));
		}
	} else {
		cons_printf("Usage: %s [filename]\n", argv[0]);
	}

	return 0;
}
Exemplo n.º 17
0
/** 
 * Returns a list of nsILocalHandlerApp objects containing local 
 * handlers associated with this mimeinfo. Implemented per 
 * platform using information in this object to generate the
 * best list. Typically used for an "open with" style user 
 * option.
 * 
 * @return nsIArray of nsILocalHandlerApp
 */
NS_IMETHODIMP
nsMIMEInfoWin::GetPossibleLocalHandlers(nsIArray **_retval)
{
  nsresult rv;

  *_retval = nsnull;

  nsCOMPtr<nsIMutableArray> appList =
    do_CreateInstance("@mozilla.org/array;1");

  if (!appList)
    return NS_ERROR_FAILURE;

  nsTArray<nsString> trackList;

  nsCAutoString fileExt;
  GetPrimaryExtension(fileExt);

  nsCOMPtr<nsIWindowsRegKey> regKey =
    do_CreateInstance("@mozilla.org/windows-registry-key;1");
  if (!regKey) 
    return NS_ERROR_FAILURE; 
  nsCOMPtr<nsIWindowsRegKey> appKey =
    do_CreateInstance("@mozilla.org/windows-registry-key;1");
  if (!appKey) 
    return NS_ERROR_FAILURE; 

  nsAutoString workingRegistryPath;

  bool extKnown = false;
  if (fileExt.IsEmpty()) {
    extKnown = true;
    // Mime type discovery is possible in some cases, through 
    // HKEY_CLASSES_ROOT\MIME\Database\Content Type, however, a number
    // of file extensions related to mime type are simply not defined,
    // (application/rss+xml & application/atom+xml are good examples)
    // in which case we can only provide a generic list.
    nsCAutoString mimeType;
    GetMIMEType(mimeType);
    if (!mimeType.IsEmpty()) {
      workingRegistryPath.AppendLiteral("MIME\\Database\\Content Type\\");
      workingRegistryPath.Append(NS_ConvertASCIItoUTF16(mimeType));
            
      rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                        workingRegistryPath,
                        nsIWindowsRegKey::ACCESS_QUERY_VALUE);
      if(NS_SUCCEEDED(rv)) {
        nsAutoString mimeFileExt;
        if (NS_SUCCEEDED(regKey->ReadStringValue(EmptyString(), mimeFileExt))) {
          CopyUTF16toUTF8(mimeFileExt, fileExt);
          extKnown = false;
        }
      }
    }
  }

  nsAutoString fileExtToUse;
  if (fileExt.First() != '.')
    fileExtToUse = PRUnichar('.');
  fileExtToUse.Append(NS_ConvertUTF8toUTF16(fileExt));

  // Note, the order in which these occur has an effect on the 
  // validity of the resulting display list.

  if (!extKnown) {
    // 1) Get the default handler if it exists
    workingRegistryPath = fileExtToUse;

    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                      workingRegistryPath,
                      nsIWindowsRegKey::ACCESS_QUERY_VALUE);
    if (NS_SUCCEEDED(rv)) {
      nsAutoString appProgId;
      if (NS_SUCCEEDED(regKey->ReadStringValue(EmptyString(), appProgId))) {
        // Bug 358297 - ignore the embedded internet explorer handler
        if (appProgId != NS_LITERAL_STRING("XPSViewer.Document")) {
          nsAutoString appFilesystemCommand;
          if (GetProgIDVerbCommandHandler(appProgId,
                                          appFilesystemCommand,
                                          false) &&
              !IsPathInList(appFilesystemCommand, trackList)) {
            ProcessPath(appList, trackList, appFilesystemCommand);
          }
        }
      }
      regKey->Close();
    }


    // 2) list HKEY_CLASSES_ROOT\.ext\OpenWithList\ 
    
    workingRegistryPath = fileExtToUse;
    workingRegistryPath.AppendLiteral("\\OpenWithList");

    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                      workingRegistryPath,
                      nsIWindowsRegKey::ACCESS_QUERY_VALUE);
    if (NS_SUCCEEDED(rv)) {
      PRUint32 count = 0;
      if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
        for (PRUint32 index = 0; index < count; index++) {
          nsAutoString appName;
          if (NS_FAILED(regKey->GetValueName(index, appName)))
            continue;

          // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
          nsAutoString appFilesystemCommand;
          if (!GetAppsVerbCommandHandler(appName,
                                         appFilesystemCommand,
                                         false) ||
              IsPathInList(appFilesystemCommand, trackList))
            continue;
          ProcessPath(appList, trackList, appFilesystemCommand);
        }
      }
      regKey->Close();
    }


    // 3) List HKEY_CLASSES_ROOT\.ext\OpenWithProgids, with the
    // different step of resolving the progids for the command handler.

    workingRegistryPath = fileExtToUse;
    workingRegistryPath.AppendLiteral("\\OpenWithProgids");

    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                      workingRegistryPath,
                      nsIWindowsRegKey::ACCESS_QUERY_VALUE);
    if (NS_SUCCEEDED(rv)) {
      PRUint32 count = 0;
      if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
        for (PRUint32 index = 0; index < count; index++) {
          // HKEY_CLASSES_ROOT\.ext\OpenWithProgids\Windows.XPSReachViewer
          nsAutoString appProgId;
          if (NS_FAILED(regKey->GetValueName(index, appProgId)))
            continue;

          nsAutoString appFilesystemCommand;
          if (!GetProgIDVerbCommandHandler(appProgId,
                                           appFilesystemCommand,
                                           false) ||
              IsPathInList(appFilesystemCommand, trackList))
            continue;
          ProcessPath(appList, trackList, appFilesystemCommand);
        }
      }
      regKey->Close();
    }


    // 4) Add any non configured applications located in the MRU list

    // HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
    // Explorer\FileExts\.ext\OpenWithList
    workingRegistryPath =
      NS_LITERAL_STRING("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\");
    workingRegistryPath += fileExtToUse;
    workingRegistryPath.AppendLiteral("\\OpenWithList");

    rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
                      workingRegistryPath,
                      nsIWindowsRegKey::ACCESS_QUERY_VALUE);
    if (NS_SUCCEEDED(rv)) {
      PRUint32 count = 0;
      if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
        for (PRUint32 index = 0; index < count; index++) {
          nsAutoString appName, appValue;
          if (NS_FAILED(regKey->GetValueName(index, appName)))
            continue;
          if (appName.EqualsLiteral("MRUList"))
            continue;
          if (NS_FAILED(regKey->ReadStringValue(appName, appValue)))
            continue;
          
          // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
          nsAutoString appFilesystemCommand;
          if (!GetAppsVerbCommandHandler(appValue,
                                         appFilesystemCommand,
                                         false) ||
              IsPathInList(appFilesystemCommand, trackList))
            continue;
          ProcessPath(appList, trackList, appFilesystemCommand);
        }
      }
    }
    

    // 5) Add any non configured progids in the MRU list, with the
    // different step of resolving the progids for the command handler.
    
    // HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
    // Explorer\FileExts\.ext\OpenWithProgids
    workingRegistryPath =
      NS_LITERAL_STRING("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\");
    workingRegistryPath += fileExtToUse;
    workingRegistryPath.AppendLiteral("\\OpenWithProgids");

    regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
                 workingRegistryPath,
                 nsIWindowsRegKey::ACCESS_QUERY_VALUE);
    if (NS_SUCCEEDED(rv)) {
      PRUint32 count = 0;
      if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
        for (PRUint32 index = 0; index < count; index++) {
          nsAutoString appIndex, appProgId;
          if (NS_FAILED(regKey->GetValueName(index, appProgId)))
            continue;

          nsAutoString appFilesystemCommand;
          if (!GetProgIDVerbCommandHandler(appProgId,
                                           appFilesystemCommand,
                                           false) ||
              IsPathInList(appFilesystemCommand, trackList))
            continue;
          ProcessPath(appList, trackList, appFilesystemCommand);
        }
      }
      regKey->Close();
    }


    // 6) Check the perceived type value, and use this to lookup the perceivedtype
    // open with list.
    // http://msdn2.microsoft.com/en-us/library/aa969373.aspx

    workingRegistryPath = fileExtToUse;

    regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                 workingRegistryPath,
                 nsIWindowsRegKey::ACCESS_QUERY_VALUE);
    if (NS_SUCCEEDED(rv)) {
      nsAutoString perceivedType;
      rv = regKey->ReadStringValue(NS_LITERAL_STRING("PerceivedType"),
                                   perceivedType);
      if (NS_SUCCEEDED(rv)) {
        nsAutoString openWithListPath(NS_LITERAL_STRING("SystemFileAssociations\\"));
        openWithListPath.Append(perceivedType); // no period
        openWithListPath.Append(NS_LITERAL_STRING("\\OpenWithList"));

        nsresult rv = appKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                                   openWithListPath,
                                   nsIWindowsRegKey::ACCESS_QUERY_VALUE);
        if (NS_SUCCEEDED(rv)) {
          PRUint32 count = 0;
          if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
            for (PRUint32 index = 0; index < count; index++) {
              nsAutoString appName;
              if (NS_FAILED(regKey->GetValueName(index, appName)))
                continue;
              
              // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
              nsAutoString appFilesystemCommand;
              if (!GetAppsVerbCommandHandler(appName, appFilesystemCommand, 
                                             false) ||
                  IsPathInList(appFilesystemCommand, trackList))
                continue;
              ProcessPath(appList, trackList, appFilesystemCommand);
            }
          }
        }
      }
    }
  } // extKnown == false


  // 7) list global HKEY_CLASSES_ROOT\*\OpenWithList\
  // Listing general purpose handlers, not specific to a mime type or file extension

  workingRegistryPath = NS_LITERAL_STRING("*\\OpenWithList");

  rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                    workingRegistryPath,
                    nsIWindowsRegKey::ACCESS_QUERY_VALUE);
  if (NS_SUCCEEDED(rv)) {
    PRUint32 count = 0;
    if (NS_SUCCEEDED(regKey->GetValueCount(&count)) && count > 0) {
      for (PRUint32 index = 0; index < count; index++) {
        nsAutoString appName;
        if (NS_FAILED(regKey->GetValueName(index, appName)))
          continue;

        // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
        nsAutoString appFilesystemCommand;
        if (!GetAppsVerbCommandHandler(appName, appFilesystemCommand,
                                       false) ||
            IsPathInList(appFilesystemCommand, trackList))
          continue;
        ProcessPath(appList, trackList, appFilesystemCommand);
      }
    }
    regKey->Close();
  }


  // 8) General application's list - not file extension specific on windows
  workingRegistryPath = NS_LITERAL_STRING("Applications");

  rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                    workingRegistryPath,
                    nsIWindowsRegKey::ACCESS_ENUMERATE_SUB_KEYS|
                    nsIWindowsRegKey::ACCESS_QUERY_VALUE);
  if (NS_SUCCEEDED(rv)) {
    PRUint32 count = 0;
    if (NS_SUCCEEDED(regKey->GetChildCount(&count)) && count > 0) {
      for (PRUint32 index = 0; index < count; index++) {
        nsAutoString appName;
        if (NS_FAILED(regKey->GetChildName(index, appName)))
          continue;

        // HKEY_CLASSES_ROOT\Applications\firefox.exe = "path params"
        nsAutoString appFilesystemCommand;
        if (!GetAppsVerbCommandHandler(appName, appFilesystemCommand,
                                       false) ||
            IsPathInList(appFilesystemCommand, trackList))
          continue;
        ProcessPath(appList, trackList, appFilesystemCommand);
      }
    }
  }

  // Return to the caller
  *_retval = appList;
  NS_ADDREF(*_retval);

  return NS_OK;
}
Exemplo n.º 18
0
void CEntityMng::ProcessEntity()
{
	worldentity_t         *entity;
	int  worldIdx;
	int  visType;
	int  idxClass;

	m_MDLMng->ClearRenderWorldLink();
	m_MDLMng->ClearBlendWorldLink();
	
	entity = m_linked;
	while( entity )
	{
		if( !entity->inuse )  
		{
			entity = entity->next;
			continue;
		}

		switch( entity->classType )
		{
		case GTH_WORLD_ENTITY_TYPE_PLAYER_POS :
			        break;
		
		case GTH_WORLD_ENTITY_TYPE_MODEL :
			visType = ChechVisibleDistance( entity->origin , entity->mins , entity->maxs , entity->radius );
			if( visType == ENTITY_OVER_THAN_VISIBLE )
			{
				m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = false;
				break;
			}

			if( Cull( entity->mins , entity->maxs , entity->origin , entity->linkedCluster ) )
				m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = false;
			else
			{
				idxClass = m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].idxClass;
				 


				if( ( visType == ENTITY_CLOSED_THAN_CHARACTER ) && m_MDLMng->m_MDLWorldClasses[ idxClass ].hideFlag )
				{
					
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].blendNext = m_MDLMng->m_linkedBlendMDLWorldEntities[ idxClass ];
					m_MDLMng->m_linkedBlendMDLWorldEntities[ idxClass ] = &m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ];
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = visType;
				}
				else
				{
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].renderNext = m_MDLMng->m_linkedRenderMDLWorldEntities[ idxClass ];
					m_MDLMng->m_linkedRenderMDLWorldEntities[ idxClass ] = &m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ];
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = visType;
				}
			}

			break;

		case GTH_WORLD_ENTITY_TYPE_TELEPORT :

			if ( g_cgv.flagChangeWorld ) break;

			visType = ChechVisibleDistance( entity->origin , entity->mins , entity->maxs , entity->radius );
			if( visType == ENTITY_OVER_THAN_VISIBLE )
			{
				m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = false;
				break;
			}

			if( Cull( entity->mins , entity->maxs , entity->origin , entity->linkedCluster ) )
				m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = false;
			else
			{
				idxClass = m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].idxClass;
				if( visType == ENTITY_CLOSED_THAN_CHARACTER )
				{
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].blendNext = m_MDLMng->m_linkedBlendMDLWorldEntities[ idxClass ];
					m_MDLMng->m_linkedBlendMDLWorldEntities[ idxClass ] = &m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ];
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = visType;
				}
				else
				{
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].renderNext = m_MDLMng->m_linkedRenderMDLWorldEntities[ idxClass ];
					m_MDLMng->m_linkedRenderMDLWorldEntities[ idxClass ] = &m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ];
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = visType;
				}
			}

			if( !ChechEffectiveDistance( entity->origin , entity->effectiveDist ) )  break;

			
			if(g_SkillLogic.CancelTransform(true)) return ;
			
			
			
			if(true == g_ifMng->m_Item_ScrollWin->IfWorldChangeing())
			{	
				g_ifMng->AddSysMessage( g_LPACK.GetMassage(LPACK_TYPE_NORMAL2, 588 ));
				return;
			}

			
			if( g_pApp->m_myCharacter->isTransform ) return ;

			worldIdx = GTH_WorldToIndex( entity->target );
			if( worldIdx < 0 ) break;
			m_spawnID = entity->spawnid;

			
			GTH_RequestChangeWorld( worldIdx, m_spawnID ); 
			break;

		case GTH_WORLD_ENTITY_TYPE_ACTIVATOR :
			if( !ChechEffectiveDistance( entity->origin , entity->effectiveDist ) )  break;
			break;

		case GTH_WORLD_ENTITY_TYPE_DEACTIVATOR :
			if( !ChechEffectiveDistance( entity->origin , entity->effectiveDist ) )  break;
			break;

		case GTH_WORLD_ENTITY_TYPE_DOOR :
			break;

		case GTH_WORLD_ENTITY_TYPE_PATH :
			ProcessPath( entity );
			break;

		case GTH_WORLD_ENTITY_TYPE_CAMERA_PATH :
			ProcessCameraPath( entity );
			break;

		case GTH_WORLD_ENTITY_TYPE_SOUND :
				
			if( !CheckEffectiveSoundDistance( entity->origin , entity->soundRangeX , entity->soundRangeY ) )
			{
				if( entity->soundInPlaying )
				{
					 
					g_musicMng->Stop ( entity->soundIdx );
					entity->soundInPlaying = false;
				}
				break;
			}
			if( entity->soundInPlaying )  break;

			g_musicMng->PlaySample ( entity->soundIdx, GTH_SOUND_PLAY_LOOP );
			entity->soundInPlaying = true;
				
				    break;

		default:
			        break;
		}

		entity = entity->next;
	}
}
Exemplo n.º 19
0
/*
	Copies with wild-cards!
	cp_cmd redirects here if it detects a wildCard in the source or destination paths.
*/
int wildcopy(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	
	FF_T_INT8	pathsrc[FF_MAX_PATH];
	FF_T_INT8	pathdest[FF_MAX_PATH];
	FF_T_INT8	tmpsrc[FF_MAX_PATH];
	FF_T_INT8	tmpdest[FF_MAX_PATH];
	FF_T_INT8	srcWild[FF_MAX_PATH];
	FF_T_INT8	destWild[FF_MAX_PATH];
	FF_DIRENT	mydir;
	FF_ERROR	Tester;
	FF_T_INT8	*p;

	if(argc != 3) {
		cons_printf("Copy command is invalid\n");
		return 0;
	}

	ProcessPath(pathsrc, argv[1], pEnv);
	ProcessPath(pathdest, argv[2], pEnv);

	p =  strstr(pathdest, "*");
	if(!p) {
		cons_printf("Missing Wildcard!\n");
		return 0;
	}
	strcpy(destWild, p);
	*p = '\0';

	p =  strstr(pathsrc, "*");
	if(!p) {
		cons_printf("Missing Wildcard!\n");
		return 0;
	}
	strcpy(srcWild, p);
	*p = '\0';

	if(!FF_strmatch(srcWild, destWild, 0)) {
		cons_printf("Source and Destination Wildcards do not match!\n");
		return 0;
	}
	
	Tester = FF_FindFirst(pEnv->pIoman, &mydir, pathsrc);

	while(!Tester) {
		if(wildCompare(srcWild, mydir.FileName)) {
			// Do Copy!
			if(!FF_strmatch(mydir.FileName, ".", 0) && !FF_strmatch(mydir.FileName, "..", 0)) {
				cons_printf("Copying file %s\n", mydir.FileName);
				strcpy(tmpsrc, pathsrc);
				strcat(tmpsrc, mydir.FileName);
				strcpy(tmpdest, pathdest);
				strcat(tmpdest, mydir.FileName);
				if(filecopy(tmpsrc, tmpdest, pEnv) == FF_ERR_FILE_OBJECT_IS_A_DIR) {
					// Recurse through a dir copy with the same wildcards.
					// Make the DIR etc.
					FF_MkDir(pEnv->pIoman, tmpdest);
				}
			}
		}

		Tester = FF_FindNext(pEnv->pIoman, &mydir);
	}

	return 0;
}
Exemplo n.º 20
0
bool CConverToMK::WriteToMKFile()
{
	filesystem::path kPath(m_pszMKFile);
	string strParentPath = kPath.parent_path().string();
	StringVector kPathSet = m_kMKFileData;
	StringVector::iterator pkIterator = kPathSet.begin();

	for (unsigned int i = 0;i < m_uiKeyStringPosition;i++)
	{
		pkIterator++;
	}

	kPathSet.insert(pkIterator,string("LOCAL_SRC_FILES := \\"));
	unsigned int uiPos = m_uiKeyStringPosition + 1;

	for (ModuleInfoMap::iterator it = m_kModuleInfoMap.begin();
		it != m_kModuleInfoMap.end();it++)
	{
		ModuleInfo kInfo = it->second;
		StringVector kStringVector = m_kFilesPathData[string(kInfo.szModuleName)];

		for (unsigned int uiIndex = 0;uiIndex < kStringVector.size();uiIndex++)
		{
			string strFullPath = kStringVector[uiIndex];
			string strProcessedPath = "";

			if (!ProcessPath(kInfo.szVCProjFile,strFullPath.c_str(),strProcessedPath))
			{
				cout << "文件 " << strFullPath << " 找不到!请检查vcproj文件" << endl;
				continue;
			}

			replace_all(strProcessedPath,"\\","/");

			if (uiIndex != kStringVector.size() - 1)
			{
				strProcessedPath = strProcessedPath + string(" \\");
			}

			kPathSet.insert(kPathSet.begin() + uiPos,strProcessedPath);
			uiPos++;
		}
	}

	ofstream kOutStream("temp.mk");
	cout << "正在写入到" << "temp.mk" << "文件里" << endl;
	progress_display kProgressDisplay(kPathSet.size());

	for (unsigned int uiIndex = 0;uiIndex < kPathSet.size();uiIndex++)
	{
		kOutStream << kPathSet[uiIndex] << endl;
		++kProgressDisplay;
		Sleep(20);
	}

	kOutStream.close();

	cout << "已经写完并且关闭文件" << endl;

	return true;
}
Exemplo n.º 21
0
XPath::PathType XPath::LookupImpl(bool bCreate)
{
	LookupState state = S_START;
	LookupInfo info = {0};

	for (LPCTSTR p = m_szPath; state < S_FINAL; ++p) {
		switch (state) {
		case S_START:
			ProcessPath(info, bCreate);
			if (!m_hXml) {
				state = S_FINAL_ERROR;
				break;
			}

			switch (*p) {
			case 0:
				state = S_FINAL_ERROR;
				break;
			case _T('@'):
				info.attrName.Begin(p + 1);
				state = S_ATTR_STEP;
				break;
			case _T('/'):
				break;
			default:
				info.nodeName.Begin(p);
				state = S_NODE_NAME;
				break;
			};
			break;

		case S_ATTR_STEP:
			switch (*p) {
			case 0:
				info.attrName.End(p);
				state = S_FINAL_ATTR;
				break;
			default:
				break;
			};
			break;

		case S_NODE_NAME:
			switch (*p) {
			case 0:
				info.nodeName.End(p);
				state = S_FINAL_NODESET;
				break;
			case _T('['):
				info.nodeName.End(p);
				state = S_NODE_OPENBRACKET;
				break;
			case _T('/'):
				info.nodeName.End(p);
				state = S_START;
				break;
			default:
				break;
			};
			break;

		case S_NODE_OPENBRACKET:
			switch (*p) {
			case 0:
				state = S_FINAL_ERROR;
				break;
			case _T('@'):
				info.attrName.Begin(p + 1);
				state = S_NODE_ATTRNAME;
				break;
			case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'):
			case _T('5'): case _T('6'): case _T('7'): case _T('8'): case _T('9'):
				info.nodeIndex.Begin(p);
				state = S_NODE_INDEX;
				break;
			default:
				state = S_FINAL_ERROR;
				break;
			};
			break;

		case S_NODE_INDEX:
			switch (*p) {
			case 0:
				state = S_FINAL_ERROR;
				break;
			case _T(']'):
				info.nodeIndex.End(p);
				state = S_NODE_CLOSEBRACKET;
				break;
			case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'):
			case _T('5'): case _T('6'): case _T('7'): case _T('8'): case _T('9'):
				break;
			default:
				state = S_FINAL_ERROR;
				break;
			};
			break;

		case S_NODE_ATTRNAME:
			switch (*p) {
			case 0:
				state = S_FINAL_ERROR;
				break;
			case _T('='):
				info.attrName.End(p);
				state = S_NODE_ATTREQUALS;
				break;
			default:
				break;
			};
			break;

		case S_NODE_ATTREQUALS:
			switch (*p) {
			case 0:
				state = S_FINAL_ERROR;
				break;
			case _T('\''):
				info.attrValue.Begin(p + 1);
				state = S_NODE_ATTRVALUE;
				break;
			default:
				state = S_FINAL_ERROR;
				break;
			};
			break;

		case S_NODE_ATTRVALUE:
			switch (*p) {
			case 0:
				state = S_FINAL_ERROR;
				break;
			case _T('\''):
				info.attrValue.End(p);
				state = S_NODE_ATTRCLOSEVALUE;
				break;
			default:
				break;
			};
			break;

		case S_NODE_ATTRCLOSEVALUE:
			switch (*p) {
			case 0:
				state = S_FINAL_ERROR;
				break;
			case _T(']'):
				state = S_NODE_CLOSEBRACKET;
				break;
			default:
				state = S_FINAL_ERROR;
				break;
			};
			break;

		case S_NODE_CLOSEBRACKET:
			switch (*p) {
			case 0:
				state = S_FINAL_NODE;
				break;
			case _T('/'):
				state = S_START;
				break;
			default:
				state = S_FINAL_ERROR;
				break;
			};
			break;
		}

		if (!*p && (state < S_FINAL))
			state = S_FINAL_ERROR;
	}

	switch (state) {
	case S_FINAL_ATTR:
		m_szParam = info.attrName.p;
		return T_ATTRIBUTE;
	case S_FINAL_NODE:
		ProcessPath(info, bCreate);
		return T_NODE;
	case S_FINAL_NODESET:
		m_szParam = info.nodeName.p;
		return T_NODESET;
	}

	return T_ERROR;
}
Exemplo n.º 22
0
bool MazeGenerator::Generate(std::vector<int> &mazearray, int x, int y)
{
	int TileX = x;
	int TileY = y;
	int VisitedCells = 1; // start point has been visited
	int CurrentCell = StartPoint;
	MyStack.push(CurrentCell);
	std::vector <int> AvailableDirections;

	while (!MyStack.empty())
	{   //check available directions. if one is found push it onto availabledirections vector
		if (TileX - 2 > 0 && !Visited[CurrentCell - 2] &&
			TileX - 1 > 0 && !Visited[CurrentCell - 1]) // If both new tile and between tile is not visited and not outside map
		{
			// tiles are 1 option to visit.
			AvailableDirections.push_back(Direction::Left);
		}
		if (TileX + 2 < MazeSizeX && !Visited[CurrentCell + 2] &&
			TileX + 1 < MazeSizeX && !Visited[CurrentCell + 1]) // If both new tile and between tile is not visited and not outside map
		{
			// tiles are 1 option to visit.
			AvailableDirections.push_back(Direction::Right);
		}
		if (TileY - 2 > 0 && !Visited[CurrentCell - (MazeSizeX*2)] &&
			TileY - 1 > 0 && !Visited[CurrentCell - MazeSizeX]) // If both new tile and between tile is not visited and not outside map
		{
			// tiles are 1 option to visit.
			AvailableDirections.push_back(Direction::Up);
		}
		if (TileY + 2 < MazeSizeY && !Visited[CurrentCell + (MazeSizeX * 2)] &&
			TileY + 1 < MazeSizeY && !Visited[CurrentCell + MazeSizeX]) // If both new tile and between tile is not visited and not outside map
		{
			// tiles are 1 option to visit.
			AvailableDirections.push_back(Direction::Down);
		}
		if (AvailableDirections.size() > 0)
		{
			std::random_shuffle(AvailableDirections.begin(), AvailableDirections.end()); // randomizes new direction for DFS

			switch (AvailableDirections[0])
			{
			case Direction::Up:
				ProcessPath(mazearray, CurrentCell - (MazeSizeX * 2), CurrentCell - MazeSizeX);
				MyStack.push(CurrentCell);
				CurrentCell -= MazeSizeX*2; 
				VisitedCells += 2;
				TileY -= 2;
				AvailableDirections.clear();
				break;
			case Direction::Down:
				ProcessPath(mazearray, CurrentCell + (MazeSizeX * 2), CurrentCell + MazeSizeX);
				MyStack.push(CurrentCell);
				CurrentCell += MazeSizeX * 2; 
				VisitedCells += 2;
				TileY += 2; 
				AvailableDirections.clear();
				break;
			case Direction::Left:
				ProcessPath(mazearray, CurrentCell - 2, CurrentCell - 1);
				MyStack.push(CurrentCell);
				CurrentCell -= 2; 
				VisitedCells += 2;
				TileX -= 2;
				AvailableDirections.clear();
				break;
			case Direction::Right:
				ProcessPath(mazearray, CurrentCell + 2, CurrentCell + 1);
				MyStack.push(CurrentCell);
				CurrentCell += 2; 
				VisitedCells += 2;
				TileX += 2;
				AvailableDirections.clear();
				break;
			}
		} // if available directions is not 0;
		else // no avialable direction to follow
		{
			// pop one from the stack to retry
			CurrentCell = MyStack.top();
			TileX = CurrentCell % MazeSizeX; // x pos in tiles
			TileY = CurrentCell / MazeSizeX; // y pos in tiles
			MyStack.pop();
		}
	}// while totalcells !=0
	return true;

}
Exemplo n.º 23
0
int cp_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
#ifdef FF_UNICODE_SUPPORT
	const wchar_t			*szpSource, *szpDestination, *szpWildCard;
#else
	const char			*szpSource, *szpDestination, *szpWildCard;
#endif
	char				szsrcPath[FF_MAX_PATH], szdestPath[FF_MAX_PATH];
	FF_DIRENT			findData;
	
	FFT_GETOPT_CONTEXT	optionContext;	// CommandLine processing
	FF_T_BOOL			bRecursive = FF_FALSE, bVerbose = FF_FALSE;	// Option Flags.
	int 				option;

	memset(&optionContext, 0, sizeof(FFT_GETOPT_CONTEXT));			// Initialise the option context to zero.

	option = FFTerm_getopt(argc, (const char **) argv, "rRvx", &optionContext);		// Get the command line option charachters.

	while(option != EOF) {											// Process Commandline options
		switch(option) {
			case 'r':
			case 'R':
				bRecursive = FF_TRUE;								// Set recursive flag if -r or -R appears on the commandline.
				break;

			case 'v':
				bVerbose = FF_TRUE;									// Set verbose flag if -v appears on the commandline.
				break;

			case 'x':
				bExternal = FF_TRUE;
				break;

			default:
				break;
		}

		option = FFTerm_getopt(argc, (const char **) argv, "rRvx", &optionContext);	// Get the next option.
	}

	szpSource 		= FFTerm_getarg(argc, (const char **) argv, 0, &optionContext);	// The remaining options or non optional arguments.
	szpDestination 	= FFTerm_getarg(argc, (const char **) argv, 1, &optionContext);	// getarg() retrieves them intelligently.
	
	if(!szpSource) {
		printf("%s: No source file argument.\n", argv[0]);			// No source file provided.
		return 0;
	}

	if(!szpDestination) {
		printf("%s: No destination file argument.\n", argv[0]);		// No destination provided.
		return 0;
	}

	ProcessPath(szsrcPath, szpSource, pEnv);						// Process the paths into absolute paths.
	ProcessPath(szdestPath, szpDestination, pEnv);

	szpWildCard = GetWildcard(szpSource);							// Get the last token of the source path. (This may include a wildCard).

	if(strchr(szpWildCard, '*')) {									// If the 'WildCard' contains a * then its a wild card, otherwise its a file or directory.
		// WildCard Copying!
		//copy_wild();
		return 0;
	}

	if(FF_FindFirst(pEnv->pIoman, &findData, szsrcPath)) {			// Get the dirent for the file or directory, to detect if its a directory.
		// Not found!
		printf("%s: %s: no such file or directory.\n", argv[0], szpSource);
		return 0;
	}

	if(!strcmp(findData.FileName, szpWildCard) && (findData.Attrib & FF_FAT_ATTR_DIR)) {
		if(!bRecursive) {											// Its a dir!
			printf("%s: omitting directory '%s'\n", argv[0], szsrcPath);
			return 0;
		}
		copy_dir(szsrcPath, szdestPath, bRecursive, bVerbose, pEnv);// Start the copying!
		return 0;
	}

	copy_file(szsrcPath, szdestPath, bVerbose, pEnv);				// Final option, its simply a file to file copy
	
	return 0;
}
Exemplo n.º 24
0
int mkfile_cmd(int xargc, char **xargv, FF_ENVIRONMENT *pEnv) {
	
	FF_FILE *f;
	FF_T_UINT32	Bytes;
	FF_T_UINT32	BytesWritten = 0;
	FF_T_UINT32 ElementSize = 0, Elements = 0, Multiplier = 0;
	FF_T_UINT32 IntBuffer[4096];	// 16Kb of Integers!
	FF_T_UINT32	i = 0, x;
	FF_T_INT8	path[FF_MAX_PATH];
	FF_ERROR	Error;

	//LARGE_INTEGER ticksPerSecond;
	//LARGE_INTEGER start_ticks, end_ticks, cputime;
	float transferRate = 0.0;

	//cputime.QuadPart = 0;

	//QueryPerformanceFrequency(&ticksPerSecond); 

	if(xargc == 5) {
		sscanf(xargv[1], "%d", &ElementSize);
		//cons_printf("%d ",ElementSize);
		if(!ElementSize) {
			cons_printf("Invalid Element Size!\n");
			return 0;
		}

		sscanf(xargv[2], "%d", &Elements);
		//cons_printf("%d ",Elements);
		if(!Elements) {
			cons_printf("Invalid Number of Elements\n");
			return 0;
		}

		sscanf(xargv[3], "%d", &Multiplier);
		//cons_printf("%d \n",Multiplier);
		if(!Multiplier) {
			cons_printf("Invalid Multiplier\n");
			return 0;
		}

		Bytes = ElementSize * Elements * Multiplier;

		//cons_printf("Creating file of size %lu Bytes (%0.2f MB) (%0.3f GB)\n", Bytes, (float)((float)Bytes / 1048576.0), (float)(((float)Bytes / 1048576.0)/1024.0));
		
		ProcessPath(path, xargv[4], pEnv);

		f = FF_Open(pEnv->pIoman, path, FF_GetModeBits("wb"), &Error);

		if(f) {
			for(x = 0; x < 4096; x++) {
			  IntBuffer[x] = i++;
			}
  
			while(Bytes) {
				//QueryPerformanceCounter(&start_ticks); 
				if(Bytes >= 4096) {
					BytesWritten += 4096;
					Bytes -= FF_Write(f, 1, 4096, (FF_T_UINT8 *) IntBuffer);
				} else {
					BytesWritten += Bytes;
					Bytes -= FF_Write(f, 1, Bytes, (FF_T_UINT8 *) IntBuffer);
				}
				//QueryPerformanceCounter(&end_ticks);
				
				//cputime.QuadPart += (end_ticks.QuadPart - start_ticks.QuadPart);
				//time = ((float)cputime.QuadPart/(float)ticksPerSecond.QuadPart);
				//transferRate = (BytesWritten / time) / 1024;

				//cons_printf("Written %0.2f MB (%7.2f KB/s)\r", (float) ((float)BytesWritten / 1048576.0), transferRate);
			}

			//cons_printf("Written %0.2f MB (%7.2f KB/s)\n", (float) ((float)BytesWritten / 1048576.0), transferRate);

			FF_Close(f);
		} else {
			cons_printf("Error opening file: %s\n", FF_GetErrMessage(Error));
		}
		
	} else {
		cons_printf("Generates a File filled with 32-bit integers.\n\n");
		cons_printf("Usage: %s [Element Size] [Elements] [Multiplier] [filename]\n\n", xargv[0]);
		cons_printf("E.g. a 1Mb File, \tFullFAT\\>%s 1024\t 1024\t 1\t 1m.dat\n", xargv[0]);
		cons_printf("E.g. a 2Mb File, \tFullFAT\\>%s 1024\t 1024\t 2\t 2m.dat\n", xargv[0]);
		cons_printf("E.g. a 2Mb File, \tFullFAT\\>%s 1024\t 1024\t 10\t 10m.dat\n", xargv[0]);
		cons_printf("E.g. a 2Mb File, \tFullFAT\\>%s 1024\t 1024\t 100\t 100m.dat\n\n", xargv[0]);
	}

	return 0;
}