bool SourceFileRez::CheckNeedsBuild(BuildInfo &info, bool check_deps) { if (!info.objectFolder.GetFullPath()) return false; if (BString(GetPath().GetExtension()).ICompare("r") != 0) return false; if (BuildFlag() == BUILD_YES) return true; BString objname(GetPath().GetBaseName()); objname << ".rsrc"; DPath objpath(info.objectFolder); objpath.Append(objname); if (!BEntry(objpath.GetFullPath()).Exists()) return true; BString tmpname(GetPath().GetBaseName()); tmpname << ".r.txt"; DPath tmppath(info.objectFolder); tmppath.Append(tmpname); if (!BEntry(tmppath.GetFullPath()).Exists()) return true; struct stat objstat; if (stat(objpath.GetFullPath(),&objstat) != 0) return false; // Fix mod times set into the future time_t now = real_time_clock(); if (GetModTime() > now) { BNode node(GetPath().GetFullPath()); node.SetModificationTime(now); } if (GetModTime() > objstat.st_mtime) return true; return false; }
bool SourceFileC::CheckNeedsBuild(BuildInfo &info, bool check_deps) { // The checks for a file needing to be built: // 1) Build flag != BUILD_MAYBE => return result // 2) Object file missing // 3) Source mod time > object mod time // 4) Dependency file needs build // The fast stuff if (!info.objectFolder.GetFullPath()) { STRACE(2,("CheckNeedsBuild: empty file path\n")); return false; } if (BuildFlag() == BUILD_YES) { STRACE(2,("%s::CheckNeedsBuild: build flag == YES\n",GetPath().GetFullPath())); return true; } // Object file existence BString objname(GetPath().GetBaseName()); objname << ".o"; DPath objpath(info.objectFolder); objpath.Append(objname); if (!BEntry(objpath.GetFullPath()).Exists()) { STRACE(2,("%s::CheckNeedsBuild: object doesn't exist\n",GetPath().GetFullPath())); return true; } // source vs object mod time struct stat objstat; if (GetStat(objpath.GetFullPath(),&objstat) != B_OK) { STRACE(2,("%s::CheckNeedsBuild: couldn't stat object\n",GetPath().GetFullPath())); return false; } // Fix mod times set into the future time_t now = real_time_clock(); if (GetModTime() > now) { BNode node(GetPath().GetFullPath()); node.SetModificationTime(now); } if (GetModTime() > objstat.st_mtime) { STRACE(2,("%s::CheckNeedsBuild: file time more recent than object time\n", GetPath().GetFullPath())); return true; } if (!check_deps) { STRACE(2,("%s::CheckNeedsBuild: dependency checking disabled for call\n", GetPath().GetFullPath())); return false; } // Dependency check BString str(GetDependencies()); if (str.CountChars() < 1) { STRACE(2,("%s::CheckNeedsBuild: initial dependency update\n", GetPath().GetFullPath())); UpdateDependencies(info); str = GetDependencies(); } if (str.CountChars() > 0) { char *pathstr; char depString[str.Length() + 1]; sprintf(depString,"%s",str.String()); pathstr = strtok(depString,"|"); while (pathstr) { BString filename(DPath(pathstr).GetFileName()); if (filename.Compare(GetPath().GetFileName()) != 0) { DPath depPath(FindDependency(info,filename.String())); if (!depPath.IsEmpty()) { struct stat depstat; if (GetStat(depPath.GetFullPath(),&depstat) == B_OK && depstat.st_mtime > objstat.st_mtime) { STRACE(2,("%s::CheckNeedsBuild: dependency %s was updated\n", GetPath().GetFullPath(),depPath.GetFullPath())); return true; } } } pathstr = strtok(NULL,"|"); } } return false; }
nsresult nsJARInputStream::ReadDirectory(char* aBuffer, PRUint32 aCount, PRUint32 *aBytesRead) { // No need to check the args, ::Read did that, but assert them at least NS_ASSERTION(aBuffer,"aBuffer parameter must not be null"); NS_ASSERTION(aBytesRead,"aBytesRead parameter must not be null"); // If the buffer contains data, copy what's there up to the desired amount PRUint32 numRead = CopyDataToBuffer(aBuffer, aCount); if (aCount > 0) { // empty the buffer and start writing directory entry lines to it mBuffer.Truncate(); mCurPos = 0; const PRUint32 arrayLen = mArray.Count(); for ( ;aCount > mBuffer.Length(); mArrPos++) { // have we consumed all the directory contents? if (arrayLen <= mArrPos) break; const char * entryName = mArray[mArrPos]->get(); PRUint32 entryNameLen = mArray[mArrPos]->Length(); nsZipItem* ze = mZip->GetItem(entryName); NS_ENSURE_TRUE(ze, NS_ERROR_FILE_TARGET_DOES_NOT_EXIST); // Last Modified Time PRExplodedTime tm; PR_ExplodeTime(GetModTime(ze->date, ze->time), PR_GMTParameters, &tm); char itemLastModTime[65]; PR_FormatTimeUSEnglish(itemLastModTime, sizeof(itemLastModTime), " %a,%%20%d%%20%b%%20%Y%%20%H:%M:%S%%20GMT ", &tm); // write a 201: line to the buffer for this item // 200: filename content-length last-modified file-type mBuffer.AppendLiteral("201: "); // Names must be escaped and relative, so use the pre-calculated length // of the directory name as the offset into the string // NS_EscapeURL adds the escaped URL to the give string buffer NS_EscapeURL(entryName + mNameLen, entryNameLen - mNameLen, esc_Minimal | esc_AlwaysCopy, mBuffer); mBuffer.Append(' '); mBuffer.AppendInt(ze->realsize, 10); mBuffer.Append(itemLastModTime); // starts/ends with ' ' if (ze->isDirectory) mBuffer.AppendLiteral("DIRECTORY\n"); else mBuffer.AppendLiteral("FILE\n"); } // Copy up to the desired amount of data to buffer numRead += CopyDataToBuffer(aBuffer, aCount); } *aBytesRead = numRead; return NS_OK; }