Exemple #1
0
// Start writing a tmpfile
FILE *lock_fopen (const char *filename, int *info)
{
    char newfile[512];
    FILE *fp;
    int  no = getpid ();

    // Get a filename that doesn't already exist
    do
    {
        sprintf (newfile, "%s_%d.tmp", filename, no++);
    }
    while ((fp = fopen_ (newfile, "r")) && (fclose_ (fp), 1));
    *info = --no;
    return fopen_ (newfile, "w");
}
Exemple #2
0
uint8_t GPX_DocumentOpen(int8_t *name, GPX_Document_t *doc)
{

	uint8_t retvalue = 0;
	uint16_t i;
	int8_t c;
	const prog_char *str;

	if(doc == NULL) return(0);
	GPX_DocumentInit(doc);														// intialize the document with resetvalues
	doc->file = fopen_(name,'a');												// open a new file with the specified filename on the memorycard.

	if(doc->file != NULL)														// could the file be opened?
	{
		retvalue = 1;															// the document could be created on the drive.
		doc->state = GPX_DOC_OPENED;											// change document state to opened. At next a placemark has to be opened.
		str = GPX_DOCUMENT_HEADER;												// write the gpx-header to the document..
		for(i= 0; i < sizeof(GPX_DOCUMENT_HEADER)-1; i++)
		{
			c = (int8_t)pgm_read_byte(str++); // get byte from flash
			fputc_(c, doc->file); // and write that to sd-card
		}
	}

	return(retvalue);
}
Exemple #3
0
u8 GPX_DocumentOpen(s8 *name, GPX_Document_t *doc)
{

	u8 retvalue = 0;

	if(doc == NULL) return(0);
	GPX_DocumentInit(doc);														// intialize the document with resetvalues
	doc->file = fopen_(name,'a');												// open a new file with the specified filename on the memorycard.

	if(doc->file != NULL)														// could the file be opened?
	{
		retvalue = 1;															// the document could be created on the drive.
		doc->state = GPX_DOC_OPENED;												// change document state to opened. At next a placemark has to be opened.
		fwrite_((void*)GPX_DOCUMENT_HEADER, sizeof(GPX_DOCUMENT_HEADER)-1,1,doc->file);// write the gpx-header to the document.
	}

	return(retvalue);
}