haoxiang-xu / surface-editor

WebCodeEditor+LLMs is a state-of-the-art web-based Code Editor that leverages the power of large language models to assist in coding. By utilizing a vector database, it establishes intricate relationships between files and code segments.
0 stars 0 forks source link

[Algorithm: Remove File by File Path Algorithm] #58

Closed haoxiang-xu closed 2 months ago

haoxiang-xu commented 7 months ago

Create new branch from dev new branch new should called "frontend_remove_filealgorithm[your name]" function should be wrote inside vecoder/frontend_application/src/COMPONENTs/explorer/explorer.js

Image

Given

  const EXPLORER_FILES = {
    fileName: "vecoder",
    fileType: "folder",
    filePath: "vecoder",
    fileExpend: true,
    files: [
      {
        fileName: "vecoder_sample",
        fileType: "folder",
        filePath: "vecoder/vecoder_sample",
        fileExpend: true,
        files: [
          {
            fileName: ".env",
            fileType: "file",
            filePath: "vecoder/vecoder_sample/.env",
            fileExpend: false,
            files: [],
          },
        ],
      },
    ],
  };

Create a JavaScript function that accepts a JSON object and a file path string as inputs. Remove the File or Folder that is on that given file path.

eg.

EXAMPLE 1.

INPUT

above json structure and

vecoder/vecoder_sample/.env

RETURN

 {
    fileName: "vecoder",
    fileType: "folder",
    filePath: "vecoder",
    fileExpend: true,
    files: [
      {
        fileName: "vecoder_sample",
        fileType: "folder",
        filePath: "vecoder/vecoder_sample",
        fileExpend: true,
        files: [
        ],
      },
    ],
  };

EXAMPLE 2.

INPUT

above json structure and

vecoder/vecoder_sample/WrongDir/

RETURN

{
   error: "unknow file dir"
}

EXAMPLE 3.

INPUT

above json structure and

vecoder

RETURN

{
    error: "root Dir can not be deleted"
},

EXAMPLE 4.

INPUT

above json structure and

vecoder/vecoder_sample

RETURN

{
    fileName: "vecoder",
    fileType: "folder",
    filePath: "vecoder",
    fileExpend: true,
    files: [],
};