directory-listing

Recursively List all directories and files

筅森魡賤 提交于 2019-12-03 02:36:31
问题 I would like to receive the following output. Suppose the directory structure on the file system is like this: -dir1 -dir2 -file1 -file2 -dir3 -file3 -file4 -dir4 -file5 -dir5 -dir6 -dir7 The output from the script must be like: Directories: /dir1 /dir1/dir2 /dir1/dir2/dir3 /dir1/dir2/dir4 /dir1/dir5 /dir1/dir5/dir6 /dir1/dir5/dir7 Files: /dir1 /dir1/dir2/file1 /dir1/dir2/file2 /dir1/dir2/dir3/file3 /dir1/dir2/dir3/file4 /dir1/dir2/dir4/file5 /dir1/dir5/dir6 /dir1/dir5/dir7 Could you tell me

How can I sort a directory listing according to name, size and last modified?

喜你入骨 提交于 2019-12-02 19:41:00
问题 I'm just trying to figure out how I can sort a directory listing according to it's name, time last modified and size. I know you can access the file's name, size, last modified with the File methods but I'm not sure how to go about sorting it. If someone can point me in the right direction it would great. public void printDirectoryContents(String path, PrintWriter writer) { File[] list = root.listFiles(); Arrays.sort(list); for ( File f : list ) { String name = f.getName(); long lastmod = f

Recursively List all directories and files

。_饼干妹妹 提交于 2019-12-02 17:26:00
I would like to receive the following output. Suppose the directory structure on the file system is like this: -dir1 -dir2 -file1 -file2 -dir3 -file3 -file4 -dir4 -file5 -dir5 -dir6 -dir7 The output from the script must be like: Directories: /dir1 /dir1/dir2 /dir1/dir2/dir3 /dir1/dir2/dir4 /dir1/dir5 /dir1/dir5/dir6 /dir1/dir5/dir7 Files: /dir1 /dir1/dir2/file1 /dir1/dir2/file2 /dir1/dir2/dir3/file3 /dir1/dir2/dir3/file4 /dir1/dir2/dir4/file5 /dir1/dir5/dir6 /dir1/dir5/dir7 Could you tell me how to keep the output of find . -type d and find . -type f into another file? Andrea Bertani In

How can I sort a directory listing according to name, size and last modified?

守給你的承諾、 提交于 2019-12-02 09:49:15
I'm just trying to figure out how I can sort a directory listing according to it's name, time last modified and size. I know you can access the file's name, size, last modified with the File methods but I'm not sure how to go about sorting it. If someone can point me in the right direction it would great. public void printDirectoryContents(String path, PrintWriter writer) { File[] list = root.listFiles(); Arrays.sort(list); for ( File f : list ) { String name = f.getName(); long lastmod = f.lastModified(); SimpleDateFormat simple = new SimpleDateFormat("dd-MMM-yyyy HH:mm"); String formatted =

How to stop Apache from listing the contents of my user directories

不想你离开。 提交于 2019-12-02 09:39:33
问题 I recently ran some penetration testing software on my web site and was surprised for it to report that one of my directory listings was publicly accessible. It is the directory of the root user which is available. http://www.example.com/~root/ Results in this page content: Index of /~root * Parent Directory * cgi-bin/ Platform: I am creating PHP websites, with Symfony on Linux with Apache. Is this something that I can configure through Apache? 回答1: You could create a .htaccess file in that

Empty HTML href leads to directory listing in IE

拥有回忆 提交于 2019-12-01 18:07:14
I have a website with separate HTML files (actually .shtml, but this is unimportant for this issue). These shtml files contain a picture, and a forward- and backbutton so I can switch back to the preview shtml file or browse to the next one, like in a gallery. All these shtml files are generated locally. I wrote some kind of generator in Java. Basically this works, the first shtml file and the last points to <a href=""....> . When the users clicks on it, nothing happens. This is the expected behaviour. It was tested in FF, Chrome, Opera and it works there, but not in IE. When I click back or

Empty HTML href leads to directory listing in IE

大憨熊 提交于 2019-12-01 18:04:28
问题 I have a website with separate HTML files (actually .shtml, but this is unimportant for this issue). These shtml files contain a picture, and a forward- and backbutton so I can switch back to the preview shtml file or browse to the next one, like in a gallery. All these shtml files are generated locally. I wrote some kind of generator in Java. Basically this works, the first shtml file and the last points to <a href=""....> . When the users clicks on it, nothing happens. This is the expected

Directory Walker for Python

≡放荡痞女 提交于 2019-11-30 09:57:32
I am currently using the directory walker from Here import os class DirectoryWalker: # a forward iterator that traverses a directory tree def __init__(self, directory): self.stack = [directory] self.files = [] self.index = 0 def __getitem__(self, index): while 1: try: file = self.files[self.index] self.index = self.index + 1 except IndexError: # pop next directory from stack self.directory = self.stack.pop() self.files = os.listdir(self.directory) self.index = 0 else: # got a filename fullname = os.path.join(self.directory, file) if os.path.isdir(fullname) and not os.path.islink(fullname):

How to disable or reprioritize IIS DirectoryListingModule under MVC module?

半城伤御伤魂 提交于 2019-11-29 10:54:05
I use an MVC folder structure where the URL routes happen to match the directory names, eg.: <proj>\My\Cool\Thing\ThingController.cs Needs to be accessible by this url: http://blahblah/My/Cool/Thing I have the MVC routing working but unfortunately when relying on default {action} & {id}, IIS Express is routing the request to DirectoryListingModule instead, since it directly matches a folder name. Directory listing is disabled of course so instead I get: The Web server is configured to not list the contents of this directory. Module DirectoryListingModule Notification ExecuteRequestHandler

Disable Directory Listing in IIS

僤鯓⒐⒋嵵緔 提交于 2019-11-28 21:31:34
In my web application all the .aspx pages resides in Pages directory. The project structure is shown below: The Home.aspx is set as Start Page and the Web.config file of the Pages folder contains: <configuration> <location path="Secured"> <system.web> <authorization> <deny users="?"/> <allow users="*"/> </authorization> </system.web> </location> </configuration> And the main Web.config has: <authentication mode="Forms"> <forms loginUrl="~/Pages/Login.aspx" timeout="2880" defaultUrl="~/Pages/Secured/Home.aspx" /> </authentication> So when the application launches it redirects to the Login page