Exemple #1
0
void sbt_file_test(){

	int       file_num = 0;
	files_st* p_file_list;
	int i;

	file_num = get_file_num("src/");
	p_file_list = (files_st*)malloc( sizeof(files_st)*file_num );
	get_file_name_list( "src/", p_file_list );
	for( i=0;i<file_num;i++ ){
		LOGD( "file name=%s", p_file_list[i].name );
	}
}
Exemple #2
0
PRIVATE save_fcb_info_t *
get_fcb_info (FSSpecPtr fsp)
{
    filecontrolblock *fcbp, *efcbp;
    INTEGER total_length, fcb_size;
    save_fcb_info_t *retval;
    char *fcbsptr;
    INTEGER swapped_vrefnum;
    LONGINT swapped_fnum;


    retval = 0;

    swapped_vrefnum = fsp->vRefNum;
    swapped_fnum = CL (get_file_num (fsp));

    fcbsptr = (char *) CL (FCBSPtr);
    total_length = CW(*(short *)fcbsptr);
    fcbp = (filecontrolblock *) ((short *)CL(FCBSPtr)+1);
    efcbp = (filecontrolblock *) ((char *)CL(FCBSPtr) + total_length);
    fcb_size = CW (FSFCBLen);
    for (; fcbp < efcbp; fcbp = (filecontrolblock *) ((char *)fcbp + fcb_size))
    {
        HVCB *vptr;

        vptr = CL (fcbp->fcbVPtr);
        if (vptr && vptr->vcbVRefNum == swapped_vrefnum
                && fcbp->fcbFlNum == swapped_fnum)
        {
            save_fcb_info_t *newp;

            newp = malloc (sizeof *newp);
            newp->refnum = (char *) fcbp - fcbsptr;
            newp->fcb = *fcbp;
            newp->next = retval;
            newp->vptr = fcbp->fcbVPtr;
            fcbp->fcbVPtr = 0; /* hide this open file */
            retval = newp;
        }
    }
    return retval;
}
Exemple #3
0
/*
 * function rotate log depends on file's size ,if the 
 * file size more than maxsize ,the file will cut apart
 * and usr can configure the maxsize 
 */
int rotate_logs(char *logpath)
{
	if (get_file_size(logpath) >= g_logfilesize_max) {
		char buf[1028] = { 0 };
		strcpy(buf, logpath);
		int len = strlen(buf);
		int num = get_file_num(logpath);

		if (num == g_logfilenum_max) {

			strcat(buf, "-");
			buf[len + 1] = g_logfilenum_max + '0' - 1;
			buf[len + 2] = '\0';
			unlink(buf);
		}


		rename_file(logpath, num);

	}

	return 0;

}