Exemplo n.º 1
0
void del(DataArchive& a, int argc, char* argv[])
{
    char  sPath[256];
    char  sPatt[256];
    char* pDirSep;
    int   nPath;

    for (int i = 0; i < argc; i++) {
        if (strchr(argv[i], '*')) {
            strcpy(sPath, argv[i]);
    
            if ((pDirSep = strrchr(sPath, '\\')) != 0) {
                strcpy(sPatt, pDirSep+1);
                *pDirSep = 0;
                nPath = strlen(sPath);
            } else if ((pDirSep = strrchr(sPath, '/')) != 0) {
                strcpy(sPatt, pDirSep+1);
                *pDirSep = 0;
                nPath = strlen(sPath);
            } else {
                strcpy(sPatt, sPath);
                sPath[0] = 0;
                nPath    = 0;
            }

            // for each file in the archive:
            for (unsigned j = 0; j < a.NumFiles(); j++) {
                DataEntry* pde = a.GetFile(j);

                if (pde) {
                    // if we are deleting from a sub-directory,
                    if (nPath) {
                        // and this file is in the sub-directory,
                        if (_strnicmp(pde->name, sPath, nPath) == 0) {
                            // and this file matches the pattern:
                            if (match(pde->name+nPath+1, sPatt)) {
                                char sName[256];
                                strcpy(sName, pde->name);
                                a.Remove(sName);
                            }
                        }
                    } else {
                        // if we are deleting from the main directory,
                        // and this file is in the main directory,
                        if (strchr(pde->name, '/') == 0) {
                            // and this file matches the pattern:
                            if (match(pde->name, sPatt)) {
                                char sName[256];
                                strcpy(sName, pde->name);
                                a.Remove(sName);
                            }
                        }
                    }
                }
            }
        } else {
            a.Remove(argv[i]);
        }
    }
}
Exemplo n.º 2
0
void ins(DataArchive& a, int argc, char* argv[])
{
    char  sPath[256];
    char* pDirSep = 0;

    for (int i = 0; i < argc; i++) {
        if (strchr(argv[i], '*')) {
            strcpy(sPath, argv[i]);

            if ((pDirSep = strrchr(sPath, '\\')) != 0)
                *pDirSep = 0;
            else if ((pDirSep = strrchr(sPath, '/')) != 0)
                *pDirSep = 0;
            else
                sPath[0] = 0;

            WIN32_FIND_DATA   find;
            LPCWSTR tmp = (LPCWSTR)argv[i];
            HANDLE h = FindFirstFile(tmp, &find);
            if (h != INVALID_HANDLE_VALUE) {
                insertFile(a, sPath, &find);

                while (FindNextFile(h,&find)) {
                    insertFile(a, sPath, &find);
                }

            FindClose(h);
            }
        }
        else {
            a.Insert(argv[i]);
        }
    }
}
Exemplo n.º 3
0
void insertFile(DataArchive& a, const char* sPath, WIN32_FIND_DATA* find)
{
    char    sFile[256];
    char    sFlat[256];
    std::string    sTemp;
    DWORD    find_attrib_forbidden =
        FILE_ATTRIBUTE_DIRECTORY |
        FILE_ATTRIBUTE_HIDDEN    |
        FILE_ATTRIBUTE_SYSTEM    |
        FILE_ATTRIBUTE_OFFLINE;

        if (sPath && *sPath) {
            sTemp = sPath;
            sTemp += '/';
            WideCharToMultiByte(CP_ACP,0,find->cFileName,-1, sFile,260, NULL, NULL);
            sTemp += sFile;
            strcpy(sFile, sTemp.c_str());
        } else {
            WideCharToMultiByte(CP_ACP,0,find->cFileName,-1, sFile,260, NULL, NULL);
        }


    if (find->dwFileAttributes & find_attrib_forbidden) {
        printf("   Skipping:  %-48s \n", sFile);
        return;
    }

    int n = strlen(sFile);

    if (n >= NAMELEN) {
        printf("   Skipping:  %-48s (NAME TOO LONG!)\n", sFile);
        return;
    }

    for (int i = 0; i < n; i++)
        sFlat[i] = tolower(sFile[i]);

    if (strstr(sFlat, ".exe")) {
        printf("   Skipping:  %-48s (executable file)\n", sFile);
    }
    else if (strstr(sFlat, ".cmd")) {
        printf("   Skipping:  %-48s (executable file)\n", sFile);
    }
    else if (strstr(sFlat, ".bat")) {
        printf("   Skipping:  %-48s (executable file)\n", sFile);
    }
    else if (strstr(sFlat, ".bin")) {
        printf("   Skipping:  %-48s (unknown file)\n", sFile);
    }
    else if (strstr(sFlat, ".db")) {
        printf("   Skipping:  %-48s (unknown file)\n", sFile);
    }
    else if (strstr(sFlat, ".dat")) {
        printf("   Skipping:  %-48s (data file)\n", sFile);
    }
    else if (strstr(sFlat, ".zip")) {
        printf("   Skipping:  %-48s (zip file)\n", sFile);
    }
    else if (strstr(sFlat, ".arc")) {
        printf("   Skipping:  %-48s (archive file)\n", sFile);
    }
    else if (strstr(sFlat, ".psd")) {
        printf("   Skipping:  %-48s (PSD file)\n", sFile);
    }
    else {
        a.Insert(sFile);
    }
}
Exemplo n.º 4
0
void insertFile(DataArchive& a, const char* sPath, WIN32_FIND_DATA* find)
{
   char     sFile[256];
   char     sFlat[256];
   DWORD    find_attrib_forbidden =
                        FILE_ATTRIBUTE_DIRECTORY |
                        FILE_ATTRIBUTE_HIDDEN    |
                        FILE_ATTRIBUTE_SYSTEM    |
                        FILE_ATTRIBUTE_OFFLINE;

   if (sPath && *sPath)
      sprintf(sFile, "%s/%s", sPath, find->cFileName);
   else
      strcpy(sFile, find->cFileName);

   if (find->dwFileAttributes & find_attrib_forbidden) {
      printf("   Skipping:  %-48s \n", sFile);
      return;
   }

   int n = strlen(sFile);

   if (n >= NAMELEN) {
      printf("   Skipping:  %-48s (NAME TOO LONG!)\n", sFile);
      return;
   }

   for (int i = 0; i < n; i++)
      sFlat[i] = tolower(sFile[i]);

   if (strstr(sFlat, ".exe")) {
      printf("   Skipping:  %-48s (executable file)\n", sFile);
   }
   else if (strstr(sFlat, ".cmd")) {
      printf("   Skipping:  %-48s (executable file)\n", sFile);
   }
   else if (strstr(sFlat, ".bat")) {
      printf("   Skipping:  %-48s (executable file)\n", sFile);
   }
   else if (strstr(sFlat, ".bin")) {
      printf("   Skipping:  %-48s (unknown file)\n", sFile);
   }
   else if (strstr(sFlat, ".db")) {
      printf("   Skipping:  %-48s (unknown file)\n", sFile);
   }
   else if (strstr(sFlat, ".dat")) {
      printf("   Skipping:  %-48s (data file)\n", sFile);
   }
   else if (strstr(sFlat, ".zip")) {
      printf("   Skipping:  %-48s (zip file)\n", sFile);
   }
   else if (strstr(sFlat, ".arc")) {
      printf("   Skipping:  %-48s (archive file)\n", sFile);
   }
   else if (strstr(sFlat, ".psd")) {
      printf("   Skipping:  %-48s (PSD file)\n", sFile);
   }
   else {
      a.Insert(sFile);
   }
}
Exemplo n.º 5
0
InterfaceProxy *DataManager::getObjectInterface(ObjectID const &id, std::string const &path_str, DataArchive const *d) const {
	DataArchive *archive = findArchive(id, path_str, d);
	return archive->getObjectInterface(id);
}
Exemplo n.º 6
0
const LinkBase DataManager::getObject(Path const& path, std::string const &path_str, DataArchive const *d) const {
	hasht id = (hasht) path.getPath();
	DataArchive *archive = findArchive(id, path_str, d);
	return archive->getObject(path, path_str);
}