TITANIUM_FUNCTION(File, modifiedAt) { const auto ctx = get_context(); const std::vector<JSValue> dateArg = { ctx.CreateNumber(static_cast<double>(modificationTimestamp().count())) }; return ctx.CreateDate(dateArg); }
int main(int argc, const char * argv[]) { int i,a[ARRAYLEN]; for (i=0; i<ARRAYLEN; i++) { a[i]=0; } if (!CreateDate(a, ARRAYLEN, 1, 100)) { printf("生成随机数不成功!\n"); return 1; } printf("原数据:"); for (i=0; i<ARRAYLEN; i++) { printf("%d ",a[i]); } printf("\n"); printf("排序后:"); for (i=0; i<ARRAYLEN; i++) { printf("%d ",a[i]); } printf("\n"); return 0; return 0; }
// Updates everything except for starting cluster and name // ONLY AFFECTS ENTRY, NOT FAT void UpdateEntry(DirectoryEntry* entry, const uint8_t attrib, const uint32_t size) { // Get the time time_t timestamp; struct tm* localTime; time(×tamp); localTime = localtime(×tamp); // Update the entry entry->attrib = (attrib) ? attrib : entry->attrib; entry->size = (size) ? size : entry->size; entry->lastModDate = CreateDate(localTime); entry->lastModTime = CreateTime(localTime); entry->accessDate = CreateDate(localTime); // Write to disk DirectoryWrite(&directory); //WriteSector(directoryBuffer + ((((char*)entry - directoryBuffer) / 512) * 512),directorySector + (((char*)entry - directoryBuffer) / 512)); }
/* * entry = empty allocated DirectoryEntry * Expects that directoryBuffer, directorySectors, directorySector are all valid * entry will be moved to a valid place in memory * DOES NOT WRITE TO DISK, JUST MEMORY */ DirectoryEntry* MakeEntry(const char* filename, const uint8_t attrib, const uint32_t size, const Directory* dir) { // Get the time time_t timestamp; struct tm* localTime; time(×tamp); localTime = localtime(×tamp); // Find a free place for this entry DirectoryEntry* entry = FindEntryFree(dir); if (!entry) { std::cout << "No free entries!" << std::endl; return 0; } // Find a free cluster uint32_t tmpCluster = FindFreeCluster(); if (tmpCluster == FAT_EOF) return 0; // Populate the entry memcpy(entry->name, filename, DOS83_MAX_LEN); entry->attrib = attrib; // Attributes entry->creationTimeLo = 0; // Creation time (milliseconds) entry->creationTimeHi = CreateTime(localTime); // Creation time (hh:mm:ss) entry->creationDate = CreateDate(localTime); // Creation date (yy:mm:dd) entry->lastModTime = entry->creationTimeHi; // Modification time entry->lastModDate = entry->creationDate; // Modification date entry->accessDate = entry->creationDate; // Creation date entry->firstClusterHi = HIWORD(tmpCluster); // First cluster entry->firstClusterLo = LOWORD(tmpCluster); // First cluster entry->size = size; // Size return entry; }