Search and read the file name in C

406 Views Asked by At

I have a scenario where I want to search my directory for all the files which have ".ip" in their filename and then read the filenames(I don't need to open the file). I also need the time-stamp for each files and store them. I am using a Linux system and would like the solution to be in C.

Here's what my directory looks like:

 MyFolder/Data
   ── server.linux.config
   ── linux.115.65.45.123:9000.ip
   ── windows.54.34.105.192:3050.ip
   ── local.127.0.0.1:8080.ip
   ── server.bin
   ── keys.bin
  

For example, I need to need to read the filename "linux.115.65.45.123:9000.ip" since it has "ip" in its file name and get ip_address "115.65.45.123", port no. "9000", system "linux" after reading the name and then the time-stamp of the file ( 2021year 10month 25day 14hour 37min 25sec).

Here by timestamp I mean when the file contents were last modified(Year, Month, Day, Hour, Minute, Second).

0

There are 0 best solutions below