예제 #1
0
	Event::Event(bool manualReset, bool initialState, const std::string& name)
		: CommonImpl< IEvent >()
		, event_(::CreateEventW(NULL, manualReset, initialState, PrepareName(name)))
	{
		if ( !event_ )
			throw std::exception();
	}
BOOL CXTPCalendarCustomProperties::RemoveProperty(LPCTSTR pcszName)
{
	return m_mapProperties.RemoveKey(PrepareName(pcszName));
}
BOOL CXTPCalendarCustomProperties::SetProperty(LPCTSTR pcszName, const COleVariant& varValue)
{
	COleVariant varVal = varValue;
	m_mapProperties.SetAt(PrepareName(pcszName), varVal);
	return TRUE;
}
BOOL CXTPCalendarCustomProperties::GetProperty(LPCTSTR pcszName, COleVariant& rVarValue) const
{
	return m_mapProperties.Lookup(PrepareName(pcszName), rVarValue);
}
예제 #5
0
파일: pack.c 프로젝트: Pavuucek/PACKwcx
// Delete entries
int PAK_Delete(char *name, char *DelList)
{
	char pname[56], a[256];
	FILE *pak;
	int n, m, offset, retval;

	totalfiles=totaldirs=0;

// create file list & calculate amount of files to be packed
	while(*DelList)
	{
		if(!isDir(DelList))
		{
			files[totalfiles++]=DelList;
			if(totalfiles==MAX_FILES_IN_PACK) return E_TOO_MANY_FILES;
		}
		while(*DelList++);
	}

	if(!totalfiles)
		return E_NO_FILES;

	retval=PAK_OpenChange(name, 0);
	if(retval) return retval;

// check for overwrite
	for(n=0; n<totalfiles; n++)
	{
		PrepareName(pname, NULL, files[n], 1);
		if(!pname[0]) continue;
		for(m=0; m<total; m++)
			if(!strcmp(entry[m].filename, pname))
		{
			memmove(&entry[m], &entry[m+1], sizeof(pakentry_t)*(total-m-1));
			total--; m--;
		}
	}

// prepare PAK file
	pak=fopen(name, "r+b");
	if(!pak)
	{
		free(entry);
		return E_EOPEN;
	}
	offset=sizeof(header);
	for(n=0; n<total; n++)
	{
// if offsets do not match move entry
		if(offset!=entry[n].offset)
		{
			move(pak, offset, entry[n].offset, entry[n].size);
			entry[n].offset=offset;

// notify WinCmd with a progress
			sprintf(a, "seeking [%d%%] %s", 100*n/total, entry[n].filename);
			ppProc(a, 0);
		}
		offset+=entry[n].size;
	}

	header.dirsize=total*sizeof(pakentry_t);
	header.diroffset=offset;
	fseek(pak, 0, SEEK_SET);
	fwrite(&header, sizeof(header), 1, pak);
	fseek(pak, offset, SEEK_SET);
	fwrite(entry, header.dirsize, 1, pak);
	offset+=header.dirsize;
	chsize(fileno(pak), offset);

	fclose(pak);
	free(entry);
	return 0;
}
예제 #6
0
파일: pack.c 프로젝트: Pavuucek/PACKwcx
int PAK_Add(char *name, char *spath, char *path, char *AddList, int flags)
{
	char fname[MAX_PATH], pname[56], a[256];
	int n, m, offset, retval;
	FILE *pak, *fp;

// file list is allready created by PAK_Pack function

	retval=PAK_OpenChange(name, totalfiles);
	if(retval) return retval;

// check for overwrite, if so, delete overwritten entry
	for(n=0; n<totalfiles; n++)
	{
		PrepareName(pname, spath, files[n], flags&PK_PACK_SAVE_PATHS);
		strlwr(entry[n].filename);
		if(!pname[0]) continue;
		for(m=0; m<total; m++)
			if(!strcmp(entry[m].filename, pname))
		{
			memmove(&entry[m], &entry[m+1], sizeof(pakentry_t)*(total-m-1));
			total--; m--;
		}
	}

// prepare PAK file
	pak=fopen(name, "r+b");
	if(!pak)
	{
		free(entry);
		return E_EOPEN;
	}

	offset=sizeof(header); // statring offset

	for(n=0; n<total; n++)
	{
// if offsets do not match move entry
		if(offset!=entry[n].offset)
		{
			move(pak, offset, entry[n].offset, entry[n].size);
			entry[n].offset=offset;

// notify WinCmd with a progress
			sprintf(a, "seeking [%d%%] %s", 100*n/total, entry[n].filename);
			ppProc(a, 0);
		}
		offset+=entry[n].size;
	}

// pack Additional files [Add]
	for(n=0; n<totalfiles; n++)
	{
		entry[total].offset=offset;
		PrepareName(entry[total].filename, spath, files[n], flags&PK_PACK_SAVE_PATHS);
		strlwr(entry[n].filename);
		if(!entry[total].filename[0]) continue;
		if(path)
			sprintf(fname, "%s%s", path, files[n]);
		else
			strcpy(fname, files[n]);
		fp=fopen(fname, "rb");
		if(!fp) continue;//{fclose(pak); free(entry); return E_EOPEN;}
		fseek(pak, offset, SEEK_SET);
		entry[total].size=cpy(pak, fp, fname);
		fclose(fp);
// move to archive
		if(flags&PK_PACK_MOVE_FILES) remove(fname);
		offset+=entry[total].size;
		total++;
	}

	header.dirsize=total*sizeof(pakentry_t);
	header.diroffset=offset;
	fseek(pak, 0, SEEK_SET);
	fwrite(&header, sizeof(header), 1, pak);
	fseek(pak, offset, SEEK_SET);
	fwrite(entry, header.dirsize, 1, pak);
	offset+=header.dirsize;
	chsize(fileno(pak), offset);

	fclose(pak);
	free(entry);

// delete all dirs
	if(flags&PK_PACK_MOVE_FILES)
	{
		for(n=totaldirs-1; n>=0; n--)
			_rmdir(dirs[n]);
	}

	return 0;
}
예제 #7
0
파일: pack.c 프로젝트: Pavuucek/PACKwcx
int PAK_Pack(char *name, char *spath, char *path, char *AddList, int flags)
{
	char fname[MAX_PATH];
	pakheader_t header;
	pakentry_t *entry;
	int n, offset;
	FILE *fp, *fp1;

	totalfiles=totaldirs=0;

// create file list & calculate amount of files to be packed
	while(*AddList)
	{
		if(!isDir(AddList))
		{
			files[totalfiles++]=AddList;
			if(totalfiles==MAX_FILES_IN_PACK) return E_TOO_MANY_FILES;
		}
		else
		{
			dirs[totaldirs++]=AddList;
			if(totaldirs==MAX_DIRS) return E_TOO_MANY_FILES;
		}
		while(*AddList++);
	}

	if(!totalfiles)
		return E_NO_FILES;
	
// are we adding to existing archive?
	if(File_Exist(name))
		return PAK_Add(name, spath, path, AddList, flags);

// prepare header
	header.magic[0]='P';
	header.magic[1]='A';
	header.magic[2]='C';
	header.magic[3]='K';
	header.dirsize=sizeof(pakentry_t)*totalfiles;

	fp=fopen(name, "wb");
	if(!fp) return E_ECREATE;
	
	entry=malloc(header.dirsize);
	if(!entry) {fclose(fp); return E_NO_MEMORY;}
	memset(entry, 0, header.dirsize);

	fwrite(&header, sizeof(header), 1, fp);
	offset=sizeof(header);

	for(n=0; n<totalfiles; n++)
	{
		entry[n].offset=offset;
		PrepareName(entry[n].filename, spath, files[n], flags&PK_PACK_SAVE_PATHS);
		strlwr(entry[n].filename);
		if(!entry[n].filename[0]) continue;
		if(path)
			sprintf(fname, "%s%s", path, files[n]);
		else
			strcpy(fname, files[n]);
		fp1=fopen(fname, "rb");
		if(!fp1) continue;//{fclose(fp); free(entry); return E_EOPEN;}
		entry[n].size=cpy(fp, fp1, fname);
		fclose(fp1);
// move to archive
		if(flags&PK_PACK_MOVE_FILES) remove(fname);
		offset+=entry[n].size;
	}
	header.diroffset=offset;
	fwrite(entry, header.dirsize, 1, fp);
	fseek(fp, 0, SEEK_SET);
	fwrite(&header, sizeof(header), 1, fp);
	fclose(fp);
// delete all dirs
	if(flags&PK_PACK_MOVE_FILES)
	{
		for(n=totaldirs-1; n>=0; n--)
			_rmdir(dirs[n]);
	}

	return 0;
}