Sublime Forum

Add API to get list of all project files

#1

Hi!

I’m currently writing a plugin for comprehensive C++ support using libclang. It has successfully replaced using Eclipse for about half a year now and I’m really happy to use Sublime for my daily work.
There’s just one catch: My plugin needs to get a list of all files in the current project. As far as I know, there is no API to do that. So I went ahead and wrote a function to walk the project directory myself using the file_include_patterns and file_exclude_patterns in the project settings. While this gives results that are close enough to what Sublime seems to be doing internally, it is awfully slow.

This is mainly because walking directories on Linux is generally slow in Python 3.3. So the startup time of my plugin is in orders of ~10 seconds for the project I’m working on which is just not what Sublime usually feels like.

I’d really like to have an API call that just returns a list of all file paths contained in the project. It’s information that Sublime has anyway so it should be fairly easy to expose. My only other option is to hack a newer version of Python into Sublime (AFAIK Python 3.4 contains a much faster implementation), but I really don’t want to go down that route!

Thanks!

5 Likes

API Suggestions
Find File in Project API
#2

Since development of ST3 seems back on track, i wanted to bump this request: the information is already available internally and it just need to be exposed in the API to be used.

0 Likes

#3

Ideally, this (currently non-existant) API would return something like:

[ { "file_name": "/path/to/file.ext", "binary": false, "excluded": false }, { "file_name": "/path/to/img.jpg", "binary": true, "excluded": false } ]

i.e. a list of dictionaries containing the following details:

  • path to file
  • whether it is a binary file
  • whether it was excluded from the project (useful to know, in case a file is in a project folder but excluded)

or something like:

{ "binary_files": ["/path/to/img.jpg", "/another/path.ext"], "included_files": ["/path/to/file.ext"], "excluded_files": [], "excluded_folders": [], "included_folders": ["/path/to", "/another"] }
2 Likes