Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]curvefs/client: fix check filetype #2729

Merged

Conversation

Cyber-SiKu
Copy link
Contributor

What problem does this PR solve?

Issue Number: #xxx

Problem Summary:

What is changed and how it works?

What's Changed:

How it Works:

test.cpp:

#include <iostream>
#include <dirent.h>
#include <sys/stat.h> // Include the header file for struct stat
#include <ostream>
#include <string>

int main() {
  struct stat statbuf;
  std::string path;
  std::cin >> path;
  if (stat(path.c_str(), &statbuf) == 0){
      if (S_ISREG(statbuf.st_mode)) {
          std::cout << "normal file" << std::endl;
      }
  }
  return 0;
}

output:

image
image
image

Side effects(Breaking backward compatibility? Performance regression?):

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@Cyber-SiKu Cyber-SiKu force-pushed the fix/curvefs/client/diskcache_filetype branch from b3e0d55 to 4261190 Compare September 1, 2023 07:27
@Cyber-SiKu Cyber-SiKu force-pushed the fix/curvefs/client/diskcache_filetype branch 3 times, most recently from de05e45 to 3125a7a Compare September 13, 2023 07:13
if (strncmp(ent->d_name, ".", 1) == 0 ||
strncmp(ent->d_name, "..", 2) == 0) {
continue;
} else if (ent->d_type == 8) {
} else if (stat(fmt::format("{}/{}", path, ent->d_name).c_str(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a function to do it:

bool IsFile(const std::string& path) {
    // do something
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a function to do it:

bool IsFile(const std::string& path) {
    // do something
}

done

@Cyber-SiKu Cyber-SiKu force-pushed the fix/curvefs/client/diskcache_filetype branch 2 times, most recently from 6ec6e30 to b9459d5 Compare September 13, 2023 07:54
@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

11 similar comments
@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu Cyber-SiKu force-pushed the fix/curvefs/client/diskcache_filetype branch from b9459d5 to 937af04 Compare September 14, 2023 10:05
@Cyber-SiKu
Copy link
Contributor Author

cicheck

7 similar comments
@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu Cyber-SiKu force-pushed the fix/curvefs/client/diskcache_filetype branch from 9eb7208 to 2c4ba31 Compare September 19, 2023 09:01
Signed-off-by: Cyber-SiKu <Cyber-SiKu@outlook.com>
@Cyber-SiKu Cyber-SiKu force-pushed the fix/curvefs/client/diskcache_filetype branch from 2c4ba31 to 3efb66b Compare September 19, 2023 09:09
@Cyber-SiKu
Copy link
Contributor Author

cicheck

25 similar comments
@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor Author

cicheck

@Cyber-SiKu Cyber-SiKu merged commit a7ccaf9 into opencurve:master Sep 20, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants