N
N
Nikita Derbenev2020-07-27 20:45:45
Android
Nikita Derbenev, 2020-07-27 20:45:45

Android how to create a folder using NDK?

I saw on the Internet only options with java. And my game uses only native code. You need to create a folder in order to write a text document to the specified address. When such a path exists, the file will be created without problems, and when such a path does not exist (I delete the folder), then the file is not created. Why is this happening?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeny Shatunov, 2020-07-27
@Nikita_yfh

The function mkdir[ ? ].
Its behavior for Android is no different from that stated in the official documentation.
You can use the stat[ ? ], or you can rely on the error code EEXISTfrom mkdir.

A
alekseyHunter, 2020-07-27
@alekseyHunter

When such a path exists, the file will be created without problems, and when such a path does not exist (I delete the folder), then the file is not created. Why is this happening?

Logically. The directory was not found, which means there is nowhere to write.
delete folder

So don't delete the folder. Users climb into folders when they run out of space.
how to create a folder?

Look towards mkdir.

S
Sergey Karbivnichy, 2020-07-27
@hottabxp

It is logical to check if the directory exists, if so, then create a file, otherwise, create a directory and a file in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question