Lines Matching refs:pFile

142 static osl_TStamp closeFileImpl(osl_TFile* pFile, oslProfileOption Flags);
143 static sal_Bool OslProfile_lockFile(const osl_TFile* pFile, osl_TLockMode eMode);
144 static sal_Bool OslProfile_rewindFile(osl_TFile* pFile, sal_Bool bTruncate);
145 static osl_TStamp OslProfile_getFileStamp(osl_TFile* pFile);
147 static sal_Char* OslProfile_getLine(osl_TFile* pFile);
148 static sal_Bool OslProfile_putLine(osl_TFile* pFile, const sal_Char *pszLine);
163 static sal_Bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile);
168 static sal_Bool writeProfileImpl (osl_TFile* pFile);
193 osl_TFile* pFile; in osl_psz_openProfile() local
231 if ( ( pFile = openFileImpl(pszProfileName, Flags ) ) == NULL ) in osl_psz_openProfile()
251 pProfile->m_pFile = pFile; in osl_psz_openProfile()
257 pProfile->m_Stamp = OslProfile_getFileStamp(pFile); in osl_psz_openProfile()
258 bRet=loadProfile(pFile, pProfile); in osl_psz_openProfile()
263 closeFileImpl(pFile,pProfile->m_Flags); in osl_psz_openProfile()
382 osl_TFile* pFile; in osl_flushProfile() local
409 pFile = pProfile->m_pFile; in osl_flushProfile()
410 if ( !( pFile != 0 && pFile->m_Handle >= 0 ) ) in osl_flushProfile()
435 static sal_Bool writeProfileImpl(osl_TFile* pFile) in writeProfileImpl() argument
446 if ( !( pFile != 0 && pFile->m_Handle >= 0 ) || ( pFile->m_pWriteBuf == 0 ) ) in writeProfileImpl()
455 nLen=strlen(pFile->m_pWriteBuf); in writeProfileImpl()
456 OSL_ASSERT(nLen == (pFile->m_nWriteBufLen - pFile->m_nWriteBufFree)); in writeProfileImpl()
459 …BytesWritten = write(pFile->m_Handle, pFile->m_pWriteBuf, pFile->m_nWriteBufLen - pFile->m_nWriteB… in writeProfileImpl()
472 free(pFile->m_pWriteBuf); in writeProfileImpl()
473 pFile->m_pWriteBuf=0; in writeProfileImpl()
474 pFile->m_nWriteBufLen=0; in writeProfileImpl()
475 pFile->m_nWriteBufFree=0; in writeProfileImpl()
1120 static osl_TStamp OslProfile_getFileStamp(osl_TFile* pFile) in OslProfile_getFileStamp() argument
1124 if ( (pFile->m_Handle < 0) || (fstat(pFile->m_Handle, &status) < 0) ) in OslProfile_getFileStamp()
1133 static sal_Bool OslProfile_lockFile(const osl_TFile* pFile, osl_TLockMode eMode) in OslProfile_lockFile() argument
1162 if (pFile->m_Handle < 0) in OslProfile_lockFile()
1200 if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 ) in OslProfile_lockFile()
1203 if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 && errno != ENOTSUP ) in OslProfile_lockFile()
1222 osl_TFile* pFile = (osl_TFile*) calloc(1, sizeof(osl_TFile)); in openFileImpl() local
1239 pFile->m_Handle = open(pszFilename, O_RDONLY); in openFileImpl()
1248 if (((pFile->m_Handle = open(pszFilename, O_RDWR | O_CREAT | O_EXCL, DEFAULT_PMODE)) < 0) && in openFileImpl()
1249 ((pFile->m_Handle = open(pszFilename, O_RDWR)) < 0)) in openFileImpl()
1251 free(pFile); in openFileImpl()
1260 if ((Flags = fcntl(pFile->m_Handle, F_GETFD, 0)) != -1) in openFileImpl()
1263 fcntl(pFile->m_Handle, F_SETFD, Flags); in openFileImpl()
1266 pFile->m_pWriteBuf=0; in openFileImpl()
1267 pFile->m_nWriteBufFree=0; in openFileImpl()
1268 pFile->m_nWriteBufLen=0; in openFileImpl()
1275 OslProfile_lockFile(pFile, bWriteable ? write_lock : read_lock); in openFileImpl()
1281 return (pFile); in openFileImpl()
1284 static osl_TStamp closeFileImpl(osl_TFile* pFile, oslProfileOption Flags) in closeFileImpl() argument
1292 if ( pFile == 0 ) in closeFileImpl()
1300 if ( pFile->m_Handle >= 0 ) in closeFileImpl()
1302 stamp = OslProfile_getFileStamp(pFile); in closeFileImpl()
1306 OslProfile_lockFile(pFile, un_lock); in closeFileImpl()
1309 close(pFile->m_Handle); in closeFileImpl()
1310 pFile->m_Handle = -1; in closeFileImpl()
1314 if ( pFile->m_pWriteBuf ) in closeFileImpl()
1316 free(pFile->m_pWriteBuf); in closeFileImpl()
1319 free(pFile); in closeFileImpl()
1328 static sal_Bool OslProfile_rewindFile(osl_TFile* pFile, sal_Bool bTruncate) in OslProfile_rewindFile() argument
1335 if (pFile->m_Handle >= 0) in OslProfile_rewindFile()
1337 pFile->m_pReadPtr = pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf); in OslProfile_rewindFile()
1342 bRet = (lseek(pFile->m_Handle, SEEK_SET, 0L) == 0L); in OslProfile_rewindFile()
1349 bRet &= (ftruncate(pFile->m_Handle, 0L) == 0); in OslProfile_rewindFile()
1361 static sal_Char* OslProfile_getLine(osl_TFile* pFile) in OslProfile_getLine() argument
1368 if ( pFile == 0 ) in OslProfile_getLine()
1373 if (pFile->m_Handle < 0) in OslProfile_getLine()
1378 Bytes = sizeof(pFile->m_ReadBuf) - (pFile->m_pReadPtr - pFile->m_ReadBuf); in OslProfile_getLine()
1383 memcpy(pFile->m_ReadBuf, pFile->m_pReadPtr, Bytes); in OslProfile_getLine()
1384 pFile->m_pReadPtr = pFile->m_ReadBuf; in OslProfile_getLine()
1386 Free = sizeof(pFile->m_ReadBuf) - Bytes; in OslProfile_getLine()
1388 if ((Max = read(pFile->m_Handle, &pFile->m_ReadBuf[Bytes], Free)) < 0) in OslProfile_getLine()
1403 pFile->m_ReadBuf[Bytes + Max] = '\0'; in OslProfile_getLine()
1407 for (pChr = pFile->m_pReadPtr; in OslProfile_getLine()
1409 (pChr < (pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf) - 1)); in OslProfile_getLine()
1412 Max = pChr - pFile->m_pReadPtr; in OslProfile_getLine()
1419 memcpy(pNewLine+nLineBytes, pFile->m_pReadPtr, Max); in OslProfile_getLine()
1424 if (pChr < (pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf) - 1)) in OslProfile_getLine()
1434 if ((pChr < (pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf))) && in OslProfile_getLine()
1436 pChr = pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf); in OslProfile_getLine()
1442 pFile->m_pReadPtr = pChr; in OslProfile_getLine()
1449 static sal_Bool OslProfile_putLine(osl_TFile* pFile, const sal_Char *pszLine) in OslProfile_putLine() argument
1457 if ( pFile == 0 || pFile->m_Handle < 0 ) in OslProfile_putLine()
1462 if ( pFile->m_pWriteBuf == 0 ) in OslProfile_putLine()
1464 pFile->m_pWriteBuf = (sal_Char*) malloc(Len+3); in OslProfile_putLine()
1465 pFile->m_nWriteBufLen = Len+3; in OslProfile_putLine()
1466 pFile->m_nWriteBufFree = Len+3; in OslProfile_putLine()
1470 if ( pFile->m_nWriteBufFree <= Len + 3 ) in OslProfile_putLine()
1474 pTmp=(sal_Char*) realloc(pFile->m_pWriteBuf,( ( pFile->m_nWriteBufLen + Len ) * 2) ); in OslProfile_putLine()
1479 pFile->m_pWriteBuf = pTmp; in OslProfile_putLine()
1480 pFile->m_nWriteBufFree = pFile->m_nWriteBufFree + pFile->m_nWriteBufLen + ( 2 * Len ); in OslProfile_putLine()
1481 pFile->m_nWriteBufLen = ( pFile->m_nWriteBufLen + Len ) * 2; in OslProfile_putLine()
1482 …memset( (pFile->m_pWriteBuf) + ( pFile->m_nWriteBufLen - pFile->m_nWriteBufFree ), 0, pFile->m_nWr… in OslProfile_putLine()
1488 memcpy(pFile->m_pWriteBuf + ( pFile->m_nWriteBufLen - pFile->m_nWriteBufFree ),pszLine,Len+1); in OslProfile_putLine()
1490 strLen = strlen(pFile->m_pWriteBuf); in OslProfile_putLine()
1492 pFile->m_pWriteBuf[pFile->m_nWriteBufLen - pFile->m_nWriteBufFree + Len]='\n'; in OslProfile_putLine()
1493 pFile->m_pWriteBuf[pFile->m_nWriteBufLen - pFile->m_nWriteBufFree + Len + 1]='\0'; in OslProfile_putLine()
1495 pFile->m_nWriteBufFree-=Len+1; in OslProfile_putLine()
1865 static sal_Bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile) in loadProfile() argument
1877 if ( pFile == 0 ) in loadProfile()
1887 OSL_VERIFY(OslProfile_rewindFile(pFile, sal_False)); in loadProfile()
1889 while ( ( pLine=OslProfile_getLine(pFile) ) != 0 ) in loadProfile()
2025 osl_TFile* pFile=0; in osl_openTmpProfileImpl() local
2046 pFile = openFileImpl(pszTmpName,pProfile->m_Flags | PFlags); in osl_openTmpProfileImpl()
2050 return pFile; in osl_openTmpProfileImpl()